简体   繁体   English

跟踪iPhone / iPad上播放一半的媒体项目的位置

[英]Tracking the position of a half played media item on iPhone/iPad

I would like to track the last position of a media item (song or podcast). 我想跟踪媒体项目(歌曲或播客)的最后位置。 I can access the total duration using the MPMediaItemPropertyPlaybackDuration property of the MPMediaItem. 我可以使用MPMediaItem的MPMediaItemPropertyPlaybackDuration属性访问总持续时间。 I am interested in way to store and track the last played position. 我对存储和跟踪最近玩过的位置感兴趣。

Does every player do this on their own ? 每个玩家都自己做吗? Would I get it for free if I just play entities with the MediaPlayer ? 如果我只是使用MediaPlayer播放实体,是否可以免费获得它?

I have not hooked media player to play items yet, I would like to understand if I need to implement my own bookmarking method. 我还没有迷上媒体播放器来播放项目,我想了解是否需要实现自己的书签方法。

[audioPlayer currentPlaybackTime]  

Will give you the current playback time. 将为您提供当前的播放时间。 I have a resume feature on a podcast player and I simply watch for interruptions with: 我在播客播放器上具有履历表功能,而我只是通过以下方式来查看中断情况:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playPlaybackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.audioPlayer];

and then inside that callback function, check the state: 然后在该回调函数中,检查状态:

 if(self.audioPlayer.playbackState == MPMoviePlaybackStateInterrupted)

and record the playback time on interruption... 并记录中断时的播放时间...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM