I have an app that interacts with both the iPod player, and the iTunes Store Web Service Search API. Is there a way to obtain the iTunes ID for a song that I retrieve from my user's iPod library (e.g. via MPMusicPlayerController, or MPMediaItem)?
The documentation says that the MPMediaItemPropertyPersistentID is a unique identifier that persists across app launch. This however, seems like it might be a unique local id.
The only solution I can think of is to retrieve the song title and artist from MPMediaItem, then query iTunes to obtain the iTunes ID. Is the iTunes ID stored anywhere locally within the iPod library?
Thanks - I am pretty new to the media framework.
The API documentation does not list a property for MPMediaItem that gives the iTunes Song ID, but it does give all of the information about a song such as the Artist and song name so, as you suggested, you could search the store for that criteria.
Related
Following this question we can get a JSON response from the iTunes Search API to direct users to the trackViewUrl. The answer suggested appending &app=itunes to have the iOS device open the URL in the iTunes Store instead of Apple Music, but my test suggests that this doesn't work and Apple Music is still opened.
For instance, the first item of the result of:
https://itunes.apple.com/search?term=pink+floyd%20high%20hopes
shows a trackViewUrl of:
https://music.apple.com/us/album/high-hopes/1067444712?i=1067444898&uo=4,
with the appended request is:
https://music.apple.com/us/album/high-hopes/1067444712?i=1067444898&uo=4&app=itunes
However, this link opens Apple Music on an iOS device.
Is there a way to open the iTunes Store instead? Or another way to open the iTunes Store to a specific track? I need DRM free tracks.
The correct way of doing this now is with StoreKit.
When sharing playlist in Apple Music app via Email, you can get a URL like this
https://itunes.apple.com/jp/playlist/if-you-like...may-j./idpl.4299b4c5a42048bd850eca538e68ace2?l=en
You will also have an URL when sharing local created playlist.
I would like to know if it is possible to get the URL programmatically on iOS using Swift.
[Effort studied but failed to solve]
Related discussion using link maker does not solve the problem
Apple Music URL Scheme
Query the playlist using: MPMediaQuery.playlists() and enumerated the returned playlist but cannot find any property showing the URL
I'm pretty sure this is not possible. I believe the playlist does not have the idpl value until the user manually presses the share button in iTunes. And, there's nothing in the API to create one.
I set up a proxy and had a look at the requests iTunes makes.
I created a playlist in iTunes and added songs to the playlist. Every song I added made several requests to various endpoints under:
https://ld-6.itunes.apple.com/WebObjects/MZDaap.woa/daap/update No idpl value in any of the responses.
Then I manually hit the share button. A request is made to
https://client-api.itunes.apple.com/WebObjects/MZStorePlatform.woa/wa/lookup with the idpl in the URL.
Now when you add more songs to the playlist, the responses contain the idpl.
From that it seems that the idpl is created on the device when the user touches share.
Probably best to file a radar for Apple to add a share URL property to MPMediaPlaylist.
EDIT: I filed a radar
Is there a way to get the iTunes Store ID for a song from an MPMediaItem?
I'm trying to pull the user's playlists, transfer those to another device, then play the songs using MPMusicPlayerController's setQueueWithStoreIDs. This would require mapping the MPMediaItems to content in the iTunes Store, which is the purpose of iTunes Match, which is included in an Apple Music subscription.
Theoretically, this should be possible for songs that were matched to iTunes content. However, I can't find a property or valueForKey on MPMediaItem or any other class in MPMediaPlayer framework that supports this. The persistentId set of properties are local DB keys and don't tie back to the iTunes content for the item. They don't seem to be the same across devices for the same user either.
This is now possible in iOS 10.3+ using the playbackStoreID instance property on MPMediaItem.
https://developer.apple.com/documentation/mediaplayer/mpmediaitem/2813404-playbackstoreid
I'm creating an iOS radio station app, and I can't find a solution to what I thought was a simple problem. If my radio station plays an song/album people want to buy, how can I just launch the iTunes Store and have it open with a search results for that track or album?
I know I can use the Apple Search API to get a json of the search results and parse that for the best search results, and I know I can open the iTunes store with https://itunes.apple.com/ (if I try to append a search string to this, I get the metadata back) or with SKStoreProductViewController if I know the product ID.
But is there a way to simply open the iTunes Store to open with search results for a song or album (or both) without having to evaluate the search metadata and send them to one (perhaps wrong) product?
Thanks!
You can do this using URL Scheme's and a tool called iTunes Link Maker. Documentation can be found for iTunes on Apple's website here
The iTunes URL scheme is used to link to content on the iTunes Music
Store. The iTunes URL format is complicated to construct, so you
create it using an online tool called iTunes Link Maker. The tool
allows you to select a country destination and media type, and then
search by song, album, or artist. After you select the item you want
to link to, it generates the corresponding URL.
http://linkmaker.itunes.apple.com/
I have a confused, I want to through the generation of playlist in the ident (eg: 0_11) to get the song name, what shoud I do and those functions can be used. thank you!
Collection Summaries in Gracenote Playlist do not store any metadata. The Collection Summary only stores the identifier for a piece of media that your application gives it. Playlists that are generated will only return these identifiers.
It is up to your application to use these identifiers to refer back to the media to do what you wish (in your case, to get the track name). Most media applications already have a media database of their own, so the identifier is normally a reference into the application's media store.
TL;DR;
You need to create a database that maps the Playlist identifiers to the song name.