
问题是:AVPlayerVIEw只显示一个循环视频.但我需要播放一个序列(4个视频).
如何让AVPlayerLooper播放所有4个视频并在此之后循环播放?
import Cocoaimport AVKitimport AVFoundationclass VIEwController: NSVIEwController { @IBOutlet weak var vIEwOne: AVPlayerVIEw! var playerLooper: AVPlayerLooper? = nil overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() let vIDeos = (1...4).map { _ in Bundle.main.urls(forResourcesWithExtension: "mov",subdirectory: nil)![Int(arc4random_uniform(UInt32(4)))] } vIEwOne.player = AVQueuePlayer(url: vIDeos[Int(arc4random_uniform(UInt32(4)))]) let item = AVPlayerItem(url: vIDeos[Int(arc4random_uniform(UInt32(4)))]) playerLooper = AVPlayerLooper(player: vIEwOne.player as! AVQueuePlayer,templateItem: item) vIEwOne.player?.actionAtItemEnd = .advance vIEwOne.controlsstyle = .none NotificationCenter.default.addobserver(self,selector: Selector(("loopSequence")),name: NSNotification.name.AVPlayerItemDidplayToEndTime,object: vIEwOne.player?.currentItem) func loopSequence() { self.vIEwOne.player?.pause() self.vIEwOne.player?.currentItem?.seek(to: kCMTimeZero,completionHandler: nil) self.vIEwOne.player?.play() } loopSequence() }}解决方法 找到之前已回答的解决方案并将其发布在评论中后,@ andy让我将其作为解决方案发布. HERE是Harish之前的回答,解决了他的问题. 总结 以上是内存溢出为你收集整理的swift – AVPlayerLooper不会循环播放多个视频全部内容,希望文章能够帮你解决swift – AVPlayerLooper不会循环播放多个视频所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)