嘿,我想让视频以不同的速率播放(慢一点)。我似乎无法正常工作。
码:
这行代码不起作用
playerLayerView.player?.rate = 0.50
完整代码:
var player = AVPlayer()
var playerLayer = AVPlayerLayer()
var playerLayerView = AVPlayerViewController()
let path = Bundle.main.path(forResource: "Video", ofType: "mov")
let prl = URL(fileURLWithPath: path!)
player = AVPlayer(url: prl)
playerLayerView.player = player
playerLayerView.view.frame = CGRect(.frame.width * 0.0, .frame.height * 0.0, .frame.width, .frame.height)
playerLayerView.videoGravity = AVLayerVideoGravity.resizeAspectFill.rawValue
playerLayerView.player?.rate = 0.50
player.seek(to: kCMTimeZero)
player.isMuted = false
page.insertSubview(playerLayerView.view, at: 0)
playerLayerView.player?.play()
唯一可以使它发挥作用的原因是。如果我立即使用play并删除.Play()
player.playImmediately(atRate: 0.50) //.rate = 1.50 //0.50, 0.67, 0.80, 1.0, 1.25, 1.50, and 2.0
最佳答案
在playerLayerView.player?.play()调用此方法之后,设置rate属性。
关于ios - 如何更改AVPlayer视频的速率,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44962441/