在使用iOS 9的新Apple Music API(发布于2016年5月12日)来开发我的音乐播放器时,我可以显示流媒体歌曲的信息,但无法显示艺术作品。我正在使用MediaPlayer、UIKit和StoreKit框架。我已经成功请求授权以添加到云音乐库和音乐目录播放。我已经成功地显示了从苹果音乐应用程序下载的歌曲中的艺术作品,以及来自我的个人歌曲收藏的艺术作品。但我看到其他人也遇到了这个问题,但都没有解决...
在此之前,我想再问一次大家是否有帮助,否则我将不得不显示默认图像(这对错误处理是必要的),或从其他服务中获取。任何帮助都将是极好的!由于这不是代码中的错误,所以我不会展示它,除非需要帮助解决这个问题。
这是我第一次尝试发布代码...这里是在一个名为Authorization的swift文件中的代码。我是否需要在任何地方引用这段代码,还是它应该在AppDelegate文件中?这是我项目中唯一不确定的部分。
import StoreKit
import MediaPlayer
import UIKit
class AppleMusicPlayer: NSObject {
let applePlayer = MPMusicPlayerController.systemMusicPlayer()
func playID(productID: String) {
SKCloudServiceController.requestAuthorization { status in
let controller = SKCloudServiceController()
controller.requestCapabilitiesWithCompletionHandler { capabilities, error in
if capabilities != SKCloudServiceCapability.None {
MPMediaLibrary.defaultMediaLibrary().addItemWithProductID(productID) { entities, error in
self.appPlayer.setQueueWithStoreIDs([productID])
self.appPlayer.shuffleMode = .Songs
self.appPlayer.play()
}
}
}
}
}
}