[英]How to change the rate of an AVPlayer video
Hey I'm trying to get a video to play at a different rate (Slower). 嘿,我想让视频以不同的速率播放(慢一点)。 I can't seem to get it to work.
我似乎无法正常工作。
Code: 码:
This line of code doesn't work 这行代码不起作用
playerLayerView.player?.rate = 0.50
Full Code: 完整代码:
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()
The only why can get it to play is. 唯一可以使它发挥作用的原因是。 If I use playImmediately and delete the .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属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.