gpt4 book ai didi

ios - 如何更改 AVPlayer 视频的速率

转载 作者:搜寻专家 更新时间:2023-11-01 06:15:59 37 4
gpt4 key购买 nike

嘿,我正在尝试让视频以不同的速率(较慢)播放。我似乎无法让它工作。

代码:

这行代码不起作用

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()

唯一能让它播放的原因是。如果我使用 playImmediately 并删除 .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() 调用此方法后设置速率属性。

关于ios - 如何更改 AVPlayer 视频的速率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44962441/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com