本文介绍了如何检测AVPlayerItem何时完成播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在查看 AVPlayerItem AVPlayer 文档,似乎没有任何回调当项目完成播放时。我希望我们可以使用某种委托回调,或者 AVPlayerActionAtItemEnd 会为我们提供自定义操作。

I've been looking through the AVPlayerItem and AVPlayer docs and there doesn't seem to be any callbacks for when the item is finished playing. I was hoping that there would be some sort of delegate callback that we can utilize or that AVPlayerActionAtItemEnd would provide a custom action for us to write.

我怎样才能找到一种方法来检测AVPlayer何时播放完一个项目?

How can i figure out a way to detect when AVPlayer has finished playing an item?

推荐答案

它使用 NSNotification 在播放结束时发出警报。

It uses NSNotification to alert when playback is finished.

注册通知:

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

完成后调用的方法:

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

这篇关于如何检测AVPlayerItem何时完成播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 09:54