简体   繁体   English

MPMusicPlayerController不能与Apple Music一起使用

[英]MPMusicPlayerController play not working with Apple Music

I am using the new Apple Music API with MPMusicPlayerController but play method doesn't work in the first time called, but after the second or third time. 我正在使用新的Apple Music API与MPMusicPlayerController,但播放方法在第一次调用时不起作用,但在第二次或第三次之后。

My code is the following: 我的代码如下:

MPMusicPlayerController *appleMusicPlayer = /*access instantiated player*/;
[appleMusicPlayer setQueueWithStoreIDs:@[url]];
[appleMusicPlayer play];

The player is instantiated as follows: 播放器实例化如下:

_appleMusicPlayer = [MPMusicPlayerController applicationMusicPlayer];
_appleMusicPlayer.repeatMode = MPMusicRepeatModeNone;
_appleMusicPlayer.shuffleMode = MPMusicShuffleModeOff;
[_appleMusicPlayer beginGeneratingPlaybackNotifications];

The url passed in setQueueWithStoreIDs method is a NSString with a country-specific valid iTunesID. 在setQueueWithStoreIDs方法中传递的url是具有特定于国家/地区的有效iTunesID的NSString。 I provide you with a screenshot of NSLog output of url after above play method is called. 在调用上面的play方法之后,我为你提供了url的NSLog输出的截图。

的NSLog

Any help would be much appreciated. 任何帮助将非常感激。

Make sure url is a string of the store ID! 确保url是商店ID的字符串!

You can get that here: https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/ 你可以在这里得到: https//affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/

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

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