ios – 如何检测AVPlayerItem何时播放?

我一直在浏览AVPlayerItem和AVPlayer文档,并且当项目完成播放时似乎没有任何回调.我希望有一些可以使用的代理回调,或者AVPlayerActionAtItemEnd将为我们提供一个自定义的动作来写入.

我如何找出一种检测AVPlayer何时完成播放项目的方法?

解决方法

播放完成后,使用NSNotification进行警报.

注册通知:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:playerItem];

完成调用的方法:

-(void)itemDidFinishPlaying:(NSNotification *) notification {
    // Will be called when AVPlayer finishes playing playerItem
}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...