【问题标题】:Get Title of Next Media/Song Item to be Played?获取要播放的下一个媒体/歌曲项目的标题?
【发布时间】:2014-05-19 00:33:25
【问题描述】:

我想创建一个名为nextItemMediaItem,这将是下一首要播放的歌曲,作为对接下来播放内容的预览。我不想播放下一个项目,只需获取它的标题即可。

当前项目是:

MPMediaItem *currentItem = [musicPlayer nowPlayingItem];

我假设下一个项目是:

MPMediaItem *nextItem = [musicPlayer nowPlayingItem + 1];

之类的,但这不起作用。在Apple docs中,有一个属性indexOfNowPlayingItem:

The index of the now playing item in the current playback queue.

@property (nonatomic, readonly) NSUInteger indexOfNowPlayingItem

所以我只是想知道如何将 MediaItem nextItem 声明为下一个要播放的曲目。然后我想在 UILabel 中显示它的标题,但我可以自己做。

我已经四处搜索,但找不到任何类似的解决方案。任何帮助将不胜感激,谢谢!

【问题讨论】:

    标签: ios mpmusicplayercontroller mpmediaitem


    【解决方案1】:

    我不知道它是否有你说的get nextItem功能。

    这目前是为了得到我要做的下一个项目:

    // MPMusicPlayerController is an iVar variable. 
    MPMusicPlaybackState state = MPMusicPlayerController.playbackState;
    [MPMusicPlayerController skipToNextItem];
    if(MPMusicPlayerController.indexOfNowPlayingItem != NSNotFound)
    {
        if(state == MPMusicPlaybackStatePlaying)
            [MPMusicPlayerController play];
        MPMediaItem *currentItem = MPMusicPlayerController.nowPlayingItem;
        // you get your currentItem and update UI
    }
    

    希望对你有所帮助

    【讨论】:

    • 这是否获得下一项的标题?它似乎会播放下一个项目
    猜你喜欢
    • 1970-01-01
    • 2011-04-10
    • 1970-01-01
    • 2013-01-14
    • 1970-01-01
    • 2015-11-20
    • 1970-01-01
    • 1970-01-01
    • 2015-10-17
    相关资源
    最近更新 更多