小编123*_*123的帖子

你如何在Swift 4中循环AVPlayer?

我使用了以下代码:

NotificationCenter.default.addObserver(self,selector: #selector(ViewController.restartVideoFromBeginning),name: NSNotification.Name.AVPlayerItemDidPlayToEndTime,object: nil)

@objc func restartVideoFromBeginning()  {


    let seconds : Int64 = 0
    let preferredTimeScale : Int32 = 1
    let seekTime : CMTime = CMTimeMake(seconds, preferredTimeScale)

    player!.seek(to: seekTime)

    player!.play()

}
Run Code Online (Sandbox Code Playgroud)

但是里面的玩家restartVideoFromBeginning有零值,有谁知道为什么?

swift

0
推荐指数
1
解决办法
1847
查看次数

标签 统计

swift ×1