用户搜索时未调用AVPlayerViewController委托函数

时间:2017-07-04 12:49:54

标签: ios iphone swift avplayer avplayerviewcontroller

我一直试图在用户搜索时从Avplayerviewcontroller收到通知。我在AvplayerControllerdelegate中找到了一个方法,当用户擦洗时调用该方法,但该函数未被调用。

class ViewController: UIViewController, AVPlayerViewControllerDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
    let url = URL(string:
        "https://dl.pagal.link/upload_file/367/382/7491/Bollywood%20MP4%20Video%20Songs%202015/Super%20Girl%20From%20China%20-%20Sunny%20Leone%20Mp4/Super%20Girl%20From%20China%20-%20Video%20Song%20-%20Sunny%20Leone%20-%20MP4.mp4")
    let player = AVPlayer(url: url!)
    let playerController = AVPlayerViewController()
    playerController.player = player
    playerController.delegate = self
    self.addChildViewController(playerController)
    self.view.addSubview(playerController.view)
    playerController.view.frame = self.view.frame

    player.play()

}


func playerViewController(_: AVPlayerViewController, timeToSeekAfterUserNavigatedFrom: CMTime, to: CMTime){
    print("Called when scrubb")
}
func playerViewController(_: AVPlayerViewController, willResumePlaybackAfterUserNavigatedFrom: CMTime, to: CMTime){
    print("Called when scrubs")
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

1 个答案:

答案 0 :(得分:5)

因为apple developer documents said,它仅适用于Apple Tv

  

在Apple TV上,您可以实现与播放导航相关的方法,   插页式内容和内容提案。

如果您为Apple TV创建应用并实施AVPlayerViewControllerDelegate,您可以看到使用此方法,但对于iphone,您无法在AVPlayerViewControllerDelegate

中找到此方法