I have been trying to get the notification from Avplayerviewcontroller
when user seek. I found a method in AvplayerControllerdelegate
which is called when user scrub however that function is not getting called.
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.
}
}
Because as apple developer documents said , its just for Apple Tv
On Apple TV, you can implement methods related to playback navigation, interstitial content, and content proposals.
If you create an app for Apple TV and implement AVPlayerViewControllerDelegate
you can see use this method but for iphone you can't find this method in AVPlayerViewControllerDelegate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.