简体   繁体   English

MPMusicPlayerController第一次不工作

[英]MPMusicPlayerController not working first time

I have implemented MPMusicPlayerController playing song functionality in the app. 我已经实现了MPMusicPlayerController在应用程序中播放歌曲的功能。 Everything working fine but very first time of launching the app is not working.Second time onwards it is working awesome. 一切正常,但是第一次启动该应用程序无法正常工作。 What I understood is setNowPlayingItem is not setting on first time . 我了解的是setNowPlayingItem不在第一次设置 Any ideas/suggestions could be very helpful. 任何想法/建议都可能非常有帮助。 Thanks for your valuable time. 感谢您的宝贵时间。

Code

    MPMediaItemCollection *collection = [[MPMediaItemCollection alloc] initWithItems:[NSArray arrayWithObjects:selectedMediaItem1, nil]];

    [appDelegate.musicPlayer setQueueWithItemCollection:collection];

    [appDelegate.musicPlayer setNowPlayingItem:selectedMediaItem1];

    [appDelegate.musicPlayer prepareToPlay];

    [appDelegate.musicPlayer play];

It's a bug! 这是一个错误! I opened a Technical Support Incident about this. 我为此开了一个技术支持事件。 We hope in iOS 10. Music and apple music will likely have a big update. 我们希望在iOS 10中能够对音乐和苹果音乐进行重大更新。

you should also set a currentPlaybackTime for your player, 您还应该为播放器设置currentPlaybackTime,

   // Restore the now-playing item and its current playback time.
    appDelegate.musicPlayer.nowPlayingItem      = nowPlayingItem;
    appDelegate.musicPlayer.currentPlaybackTime = currentPlaybackTime;

Check this link for more details: https://developer.apple.com/library/ios/documentation/Audio/Conceptual/iPodLibraryAccess_Guide/UsingMediaPlayback/UsingMediaPlayback.html 检查此链接以获取更多详细信息: https : //developer.apple.com/library/ios/documentation/Audio/Conceptual/iPodLibraryAccess_Guide/UsingMediaPlayback/UsingMediaPlayback.html

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

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