0

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 an Apple Music subscription.

I have seen countless apps being able to search for Apple Music songs without asking the users consent for their Apple Music or anything like that.

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)

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!

Kev Wats
  • 896
  • 1
  • 5
  • 13
loveSO123
  • 11
  • 2

1 Answers1

1

I don’t know about the native APIs, but: Apple makes available anonymous-access web APIs for searching, which date back to the iTunes Store: https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/iTuneSearchAPI/index.html

Songs available via Apple Music can be found using that API.

Michael
  • 409
  • 4
  • 11