I'm adapting my app to Swift 3 and I'm encountering this problem. This used to work on Swift 2.2 but now it's broken. moviePlayBackFinished never gets called. I tried adding the observer in multiple ways, all without success.
NotificationCenter.default.addObserver(self, selector: #selector(self.moviePlayBackFinished(_:)),
name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem);
NotificationCenter.default.addObserver(self, selector: #selector(moviePlayBackFinished(_:)),
name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem);
NotificationCenter.default.addObserver(self, selector: #selector(self.moviePlayBackFinished(sender:)),
name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem);
// (...)
@objc func moviePlayBackFinished(sender : AnyObject) {
print("playbackFinished");
let zeroCM : CMTime = CMTime(seconds: 0, preferredTimescale: 1000000000);
playerLayer.player?.seek(to: zeroCM);
}
@objc func moviePlayBackFinished(_ notification: Notification) {
print("playbackFinished");
let zeroCM : CMTime = CMTime(seconds: 0, preferredTimescale: 1000000000);
playerLayer.player?.seek(to: zeroCM);
}
Any ideas would be appriciated.
Thank you
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)