In my music player using the new Apple Music API (released May 12, 2016) in iOS 9 (quickly, although I am still familiar with Objective-C), I can display information from a streaming song, but not a work of art. I use MediaPlayer, UIKit, and StoreKit environments. I have successfully requested permission for AddToCloudMusicLibrary and MusicCatalogPlayback. I have success showing the work of Apple Music from songs that I downloaded from the Apple Music app, as well as illustrations from my personal song collection. I saw other people with problems about this, with no luck ...
Just try to ask again, for people, before starting to display the default image (which is necessary in any case for error handling) or pull it out of an alternative service. Any help would be great! This is actually not an error in my code, so I won’t show it unless I’m asked to help solve this problem.
My first attempt at publishing code ... Here's what I have in a quick file called "Authorization". Do I need to reference this code somewhere or should it be in the AppDelegate file? This is the only part of my project on which I am not 100% sure.
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()
}
}
}
}
}
}
source
share