代码之家  ›  专栏  ›  技术社区  ›  arachide

使用mpMusicPlayerController播放mpMediaItemCollection,如何获取播放结束时的事件

  •  3
  • arachide  · 技术社区  · 14 年前

    我用的是 MPMusicPlayerController MPMediaItems 在一个 MPMediaItemCollection . 当 MPMediaItem 玩完了吗?

    谢谢! Interdev公司

    1 回复  |  直到 11 年前
        1
  •  5
  •   Michal    11 年前

    MPMusicPlayerControllerPlaybackStateDidChangeNotification

    [notificationCenter addObserver:self selector:@selector(handlePlaybackStateChanged:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:self.musicPlayer];
    

    [self.musicPlayerController beginGeneratingPlaybackNotifications];
    

    handlePlaybackStateChanged: playbackState

    - (void)handlePlaybackStateChanged:(NSNotitication*)notification
    {
        if (self.musicPlayerController.playbackState == MPMusicPlaybackStateStopped ||
            self.musicPlayerController.playbackState == MPMusicPlaybackStateInterrupted ||
            self.musicPlayerController.playbackState == MPMusicPlaybackStatePaused) {
            // do your stuff
        }
    }