I am new to the Apple Music API and MediaPlayer frameworks... I am simply trying to fetch songs from a search query, from Apple Music API, BUT, importantly, without the users need to have a Apple Music subscription.
I have seen countless apps (for example Coverstar) being able to search for Apple Music songs and play a preview without asking the users consent for their Apple Music or anything like that... (user does not need a Apple Music Subcription).
This is my current code:
let predicate = MPMediaPropertyPredicate(value: "1459938538", forProperty: MPMediaItemPropertyAlbumPersistentID) let iCloudPredicate = MPMediaPropertyPredicate(value: true, forProperty: MPMediaItemPropertyIsCloudItem) let query = MPMediaQuery.albums() query.filterPredicates = [predicate, iCloudPredicate] let mp = MPMusicPlayerController.applicationMusicPlayer mp.setQueue(with: query) mp.play()
This I have put for testing purposes simply in the ViewDidload of a viewController. The link from this code is for a web Apple Music Madonna album for example.. (from this question: Playing (non library) Apple Music content - request fails)
I have also consulted Apple's WWDC 2017 session on this with no avail... (https://developer.apple.com/videos/play/wwdc2017/502/)
So how do I do this? The answer in the question spoke of using web search Apple Music, but does not provide any explanation or further links...
Any help on this would be greatly appreciated! Thx!
I have seen countless apps (for example Coverstar) being able to search for Apple Music songs and play a preview without asking the users consent for their Apple Music or anything like that... (user does not need a Apple Music Subcription).
This is my current code:
let predicate = MPMediaPropertyPredicate(value: "1459938538", forProperty: MPMediaItemPropertyAlbumPersistentID) let iCloudPredicate = MPMediaPropertyPredicate(value: true, forProperty: MPMediaItemPropertyIsCloudItem) let query = MPMediaQuery.albums() query.filterPredicates = [predicate, iCloudPredicate] let mp = MPMusicPlayerController.applicationMusicPlayer mp.setQueue(with: query) mp.play()
This I have put for testing purposes simply in the ViewDidload of a viewController. The link from this code is for a web Apple Music Madonna album for example.. (from this question: Playing (non library) Apple Music content - request fails)
I have also consulted Apple's WWDC 2017 session on this with no avail... (https://developer.apple.com/videos/play/wwdc2017/502/)
So how do I do this? The answer in the question spoke of using web search Apple Music, but does not provide any explanation or further links...
Any help on this would be greatly appreciated! Thx!