MusicKit JS

RSS for tag

Add an Apple Music player to your web app using MusicKit JS.

Posts under MusicKit JS tag

120 Posts

Post

Replies

Boosts

Views

Activity

Find Apple song in other storefronts
I'm working on an application that matches tracks from Spotify using an ISRC. I'm using this endpoint: https://api.music.apple.com/v1/catalog/us/songs?filter[isrc]=USQE92100257 example is taken from here: https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_songs_by_isrc Every now and then we won't be able to find a specific song even though it exists in Apple's library but under a different storefront. By default, we're using the "US" storefront, but tracks may be available in say "GB" or some other storefront. Is there a way to search multiple storefronts when this happens? I know I could change the storefront value in the endpoint, but this is impractical as we often use tracks available in multiple countries. Is there an endpoint that allows me to search if a song is available on any storefront? On another note, does the Apple player from the Apple Music Kit JS utilize specific storefronts when playing music, or is it just based on having a valid Apple Id? Meaning if 3 songs came from the US storefront but a 4th one was from GB would that affect playback?
0
0
964
Oct ’22
******* Apple Music - API - How Much Support? Right Choice?
Hello all! I have a web app mostly developed in JSON. Can I add Apple Music to it and can I do things like: See what songs are being played and play back the most listened to? Grab lyrics and show them on the screen? We have a communication side - can we listen to a song together during a video call? Is Apple Music the best choice for my application? Thanks all!
0
0
1.1k
Sep ’22
MusicKit instance seek to time error
I am using apple MusicKit to song streaming based on action per seconds at specific seconds i try to stop the playing music and start the next on on the queue. i alwyas get this error i am sure that i stopped and then try to play and seekToTime. this is my next function : async function next(time) { const music = MusicKit.getInstance(); await music.skipToNextItem(); await music.play(); await music.seekToTime(time); return; } this is it's call in condition : music.stop().then(function () { next(100) });`
0
0
1.2k
Aug ’22
User Library music not available when considered "now playing"
I have a few reports of users with music purchased outside iTunes/Apple Music not displaying the album artwork when they play it. I was able to reproduce this on my end, but not sure why this would be happening. Is there a setting that needs to be enabled from Apple Music when adding external music? From my end, is there anything I need to when calling setQueue? async playAlbum(album: string, startPosition: number, shuffle = false) { this.toggleShuffle(shuffle); await this.mkInstance.setQueue({ album, startPosition }); await this.play(); } Right now, I just pass the album ID and call that. Should I be doing this differently?
0
0
1.2k
Jul ’22
Status Code 40015 Error Occurred in Apple Music API "add_a_resource_to_a_library"
When using the Apple Music API add_a_resource_to_a_library with Musickit JS, the following status code 40015 error occurred. {"errors":[{"id":"26-digit-ID","title":"Insufficient Privileges","detail":"User's subscription tier does not have access to privilege: ListeningHistory","status":"400","code":"40015","messageForDisplay":"Insufficient Privileges"}]} This error is not listed in the Response Codes in the API documentation for this endpoint. (1) Are there any details about the cause of this error or other details described anywhere in the API documentation? (2) Are there any other errors that may occur besides this error that are not listed in the documentation for this endpoint?
0
0
753
Jul ’22
MusicKitJS in embedded webview cannot authenticate
When working with embedded web content inside a native app, any calls to MusicKit.authorize will not be properly authenticate. Calling authenticate will open Safari, allow the user to login, then ask for user confirmation, but the window will not navigate back to the native app. Is it expected that developers would have to enable associated domains for the native app?
1
0
917
Jul ’22
MusicKit JS v3 authentication failure
When attempting to authenticate with the musickit-js v3, the page that gets loaded from authorize.music.apple.com results in an error "Cannot parse response" On the desktop, this does not happen. The authentication code in question is async login() { const mkInst = MusicKit.getInstance(); await mkInst.authorize(); } Not sure if this is limited to V3, as it's technically not officially released, but figured it was worth bringing to attention.
3
0
1.4k
Jul ’22
MusicKit v3 previewOnly does nothing
The documentation states that setting this property to true makes the player only play previews, even when authorization is available. I am using it like this: async function playPreview(songId) { const music = window.MusicKit.getInstance(); music.previewOnly = true; await music.setQueue({song: songId, startPlaying: true}); } This still makes the entire song play. I have cross-checked that I am indeed loading MusicKit v3 (MusicKit.version returns '3.2226.3-prerelease'). Is the documentation wrong here, or am I missing something?
1
0
882
Jul ’22
Music Kit JS with Multiple Songs (not in playlist)
I'm trying to stream an array of Apple music songs that are not tied to a single playlist. I have all the id's of these songs and I can play them individually if I use "setQueue" such as this:    await musicKit.value.setQueue({   songs: ["1616228595", "1564530724"],     autoplay: true,     }); After the first song finishes playing it just stops altogether. How can I have the next song in the array play? I'm able to use:   await musicKit.value.skipToNextItem();   await musicKit.value.skipToPreviousItem(); And that works fine to toggle between the songs in the array, but I haven't found anything that shows an example of how this would be done with an array of songs such as I have. What do I need to add in order to get this playing songs back to back in from the song array?
6
0
1.9k
Jun ’22
MusicKit JS finding 81 playlists I don't have
Hey All, I am in the middle of developing a little web app using MusicKit JS, and I deleted all my playlists so I could do a little testing. But when I get all library playlists, the query returns 81 phantom playlists. The playlists don't have names in the JSON, so I can't work out their source. It doesn't show any of the playlists I have added and just keeps returning 81 phantom library playlists. When I tested my code using another person's Apple ID, it works perfectly, retuning all the playlists in their library. Is there a way to reset the library or fix this? I am using V1 of the MusicKit library. Thanking everyone in advance. Jacko
1
0
623
Jun ’22
Music Kit JS SeekToTime
I'm trying to use the seekToTime instance method as shown here: https://developer.apple.com/documentation/musickitjs/musickit/player/2992768-seektotime I don't know what "time" is, is this in seconds or milliseconds? I assume it's in seconds but I figure I'd ask anyway. I am currently using it in this way:   await musicKit.play();   await musicKit.seekToTime(10); This technically works, although it plays first from the start and then abruptly changes to play based on the "time" provided in the seekToTime method. I tried using the seek method before playing but that throws an error. Same thing if I "chain" these together using seekToTime first "then" play the music. Is there a "smoother" way to start playing at a specific time without this abrupt change?
2
0
1.4k
Jun ’22
New MusicKit JS release?
Is there any sign of an update to MusicKit JS? The 1.x version still seems to be the only one available despite updates to the iOS and MacOS SDKs. The 1.x version has been fairly unreliable for me and I've paused updates to Apple Music support in my app in hopes that a better version is coming soon.
4
0
1.8k
Jun ’22
adamId not found Music Kit JS
I'm testing out a dynamic song list to be queued up with Music Kit JS. When testing with a few tracks everything seemed to be working fine but then I ran into this error: The Id in question is Nirvana's "Smells Like Teen Spirit". I retrieved this Id through the Apple Music API and I double-checked it to make sure it was correct and it is. This appeared for a few tracks. I used this API endpoint to verify it was correct: https://api.music.apple.com/v1/catalog/us/songs?filter[isrc]=USGF19942501 this one as well: https://api.music.apple.com/v1/catalog/us/songs/483164390 The ISRC matches that Id, and I can see it directly from the apple id as well. Why does this appear? From everything I see that song does exist and I can play it fine on Apple Music, so why can't I play this through the Music Kit JS instance?
1
0
1.3k
Jun ’22
Music Kit JS Reload Page
I'm trying to figure out if an event gets called whenever I'm streaming with the music kit player and I reload the page. I'm using Chrome and when I reload the page the streaming music stops and says the browser prevented playing without user interaction. Events I have listeners for include: mediaPlaybackError nowPlayingItemDidChange playbackStateDidChange queueIsReady queueItemsDidChange mediaCanPlay Each of these are associated with a console message so I can track when they get called. This is what appears in my console when I start a playlist: I thought that the "mediaPlaybackError" would be called but it wasn't, and no other errors seem to pop up. The documentation here: https://developer.apple.com/documentation/musickitjs/musickit/events doesn't really explain much about the events.
4
0
1.3k
Jun ’22
How can I get more than 100 songs in the queue from playlist in MusicKit JS?
I'm using MusicKit JS v1, and I've noticed that I can't seem to get playlists with more than 100 songs to shuffle and play past the first 100. The limitation is that the API call made with MusicKit JS default fetch (I'm using the tracks relationship in a playlist) is capped at 100, and I get a 400 error code whenever I try to raise the limit. On the other hand, I can't figure out how to just get the next 100, because I can't seem to get the offset parameter to work correctly in MusicKit JS either. Any recommendations? For reference, something like the below just doesn't work (it only retrieves the first 100 songs or throws an error). await appleMusicState.musicKit.api.playlist(selectedPlaylist.id, {limit: 200}) .then(playlist => { console.log(playlist); }) nor does directly trying to setQueue with the playlist ID await appleMusicState.musicKit.setQueue({playlist: selectedPlaylist.id});
1
0
1.5k
Jun ’22
Ask user for his Media ID in a B2B app
Hi, I'm developing a B2B web-app which will be only used internally by other businesses that already are subscribed to the Apple Developer Program. This app has to communicate with the MusicKit API. I'd like to know if I can ask those business to create a Media ID from their developer account and insert their Team ID, Key ID and Secret in my app, in order to be able to generate a token. I'd like to do so in order to avoid any possible request rate limit on my account in case I made the app use my Media ID for all their requests. Is it possible or doing so I may violate any Apple license aggreement? I can't find this answer anywhere
0
0
1.1k
May ’22
Find Apple song in other storefronts
I'm working on an application that matches tracks from Spotify using an ISRC. I'm using this endpoint: https://api.music.apple.com/v1/catalog/us/songs?filter[isrc]=USQE92100257 example is taken from here: https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_songs_by_isrc Every now and then we won't be able to find a specific song even though it exists in Apple's library but under a different storefront. By default, we're using the "US" storefront, but tracks may be available in say "GB" or some other storefront. Is there a way to search multiple storefronts when this happens? I know I could change the storefront value in the endpoint, but this is impractical as we often use tracks available in multiple countries. Is there an endpoint that allows me to search if a song is available on any storefront? On another note, does the Apple player from the Apple Music Kit JS utilize specific storefronts when playing music, or is it just based on having a valid Apple Id? Meaning if 3 songs came from the US storefront but a 4th one was from GB would that affect playback?
Replies
0
Boosts
0
Views
964
Activity
Oct ’22
******* Apple Music - API - How Much Support? Right Choice?
Hello all! I have a web app mostly developed in JSON. Can I add Apple Music to it and can I do things like: See what songs are being played and play back the most listened to? Grab lyrics and show them on the screen? We have a communication side - can we listen to a song together during a video call? Is Apple Music the best choice for my application? Thanks all!
Replies
0
Boosts
0
Views
1.1k
Activity
Sep ’22
Can i get user token in my android app without download apple music android app?
I want play whole song frome apple music in my android app ,but the musickit for android tell me ,we should download apple music app.if it has other ways? or use musickit for web api in android app?
Replies
0
Boosts
0
Views
852
Activity
Sep ’22
MusicKit instance seek to time error
I am using apple MusicKit to song streaming based on action per seconds at specific seconds i try to stop the playing music and start the next on on the queue. i alwyas get this error i am sure that i stopped and then try to play and seekToTime. this is my next function : async function next(time) { const music = MusicKit.getInstance(); await music.skipToNextItem(); await music.play(); await music.seekToTime(time); return; } this is it's call in condition : music.stop().then(function () { next(100) });`
Replies
0
Boosts
0
Views
1.2k
Activity
Aug ’22
User Library music not available when considered "now playing"
I have a few reports of users with music purchased outside iTunes/Apple Music not displaying the album artwork when they play it. I was able to reproduce this on my end, but not sure why this would be happening. Is there a setting that needs to be enabled from Apple Music when adding external music? From my end, is there anything I need to when calling setQueue? async playAlbum(album: string, startPosition: number, shuffle = false) { this.toggleShuffle(shuffle); await this.mkInstance.setQueue({ album, startPosition }); await this.play(); } Right now, I just pass the album ID and call that. Should I be doing this differently?
Replies
0
Boosts
0
Views
1.2k
Activity
Jul ’22
Is it possible to get a few seconds of paid music
Is it possible to get a few seconds of paid music through the Apple Music api, so that the users of my app can use it to make commercial videos and save to their albums?
Replies
0
Boosts
0
Views
1.2k
Activity
Jul ’22
User Authorization to your application: Display the app name instead of the domain name?
Hey all - I've noticed that when you launch the login procedure from a custom MusicKit powered app, instead of using the app name (eg. "Apple Music for Vestaboard") it shows the domain name I'm hosting my app at. Is there a way - some META tag or something - to make it use my app name instead?
Replies
1
Boosts
0
Views
1.3k
Activity
Jul ’22
Status Code 40015 Error Occurred in Apple Music API "add_a_resource_to_a_library"
When using the Apple Music API add_a_resource_to_a_library with Musickit JS, the following status code 40015 error occurred. {"errors":[{"id":"26-digit-ID","title":"Insufficient Privileges","detail":"User's subscription tier does not have access to privilege: ListeningHistory","status":"400","code":"40015","messageForDisplay":"Insufficient Privileges"}]} This error is not listed in the Response Codes in the API documentation for this endpoint. (1) Are there any details about the cause of this error or other details described anywhere in the API documentation? (2) Are there any other errors that may occur besides this error that are not listed in the documentation for this endpoint?
Replies
0
Boosts
0
Views
753
Activity
Jul ’22
MusicKitJS in embedded webview cannot authenticate
When working with embedded web content inside a native app, any calls to MusicKit.authorize will not be properly authenticate. Calling authenticate will open Safari, allow the user to login, then ask for user confirmation, but the window will not navigate back to the native app. Is it expected that developers would have to enable associated domains for the native app?
Replies
1
Boosts
0
Views
917
Activity
Jul ’22
MusicKit JS v3 authentication failure
When attempting to authenticate with the musickit-js v3, the page that gets loaded from authorize.music.apple.com results in an error "Cannot parse response" On the desktop, this does not happen. The authentication code in question is async login() { const mkInst = MusicKit.getInstance(); await mkInst.authorize(); } Not sure if this is limited to V3, as it's technically not officially released, but figured it was worth bringing to attention.
Replies
3
Boosts
0
Views
1.4k
Activity
Jul ’22
MusicKit v3 previewOnly does nothing
The documentation states that setting this property to true makes the player only play previews, even when authorization is available. I am using it like this: async function playPreview(songId) { const music = window.MusicKit.getInstance(); music.previewOnly = true; await music.setQueue({song: songId, startPlaying: true}); } This still makes the entire song play. I have cross-checked that I am indeed loading MusicKit v3 (MusicKit.version returns '3.2226.3-prerelease'). Is the documentation wrong here, or am I missing something?
Replies
1
Boosts
0
Views
882
Activity
Jul ’22
Music Kit JS with Multiple Songs (not in playlist)
I'm trying to stream an array of Apple music songs that are not tied to a single playlist. I have all the id's of these songs and I can play them individually if I use "setQueue" such as this:    await musicKit.value.setQueue({   songs: ["1616228595", "1564530724"],     autoplay: true,     }); After the first song finishes playing it just stops altogether. How can I have the next song in the array play? I'm able to use:   await musicKit.value.skipToNextItem();   await musicKit.value.skipToPreviousItem(); And that works fine to toggle between the songs in the array, but I haven't found anything that shows an example of how this would be done with an array of songs such as I have. What do I need to add in order to get this playing songs back to back in from the song array?
Replies
6
Boosts
0
Views
1.9k
Activity
Jun ’22
MusicKit JS finding 81 playlists I don't have
Hey All, I am in the middle of developing a little web app using MusicKit JS, and I deleted all my playlists so I could do a little testing. But when I get all library playlists, the query returns 81 phantom playlists. The playlists don't have names in the JSON, so I can't work out their source. It doesn't show any of the playlists I have added and just keeps returning 81 phantom library playlists. When I tested my code using another person's Apple ID, it works perfectly, retuning all the playlists in their library. Is there a way to reset the library or fix this? I am using V1 of the MusicKit library. Thanking everyone in advance. Jacko
Replies
1
Boosts
0
Views
623
Activity
Jun ’22
Music Kit JS SeekToTime
I'm trying to use the seekToTime instance method as shown here: https://developer.apple.com/documentation/musickitjs/musickit/player/2992768-seektotime I don't know what "time" is, is this in seconds or milliseconds? I assume it's in seconds but I figure I'd ask anyway. I am currently using it in this way:   await musicKit.play();   await musicKit.seekToTime(10); This technically works, although it plays first from the start and then abruptly changes to play based on the "time" provided in the seekToTime method. I tried using the seek method before playing but that throws an error. Same thing if I "chain" these together using seekToTime first "then" play the music. Is there a "smoother" way to start playing at a specific time without this abrupt change?
Replies
2
Boosts
0
Views
1.4k
Activity
Jun ’22
New MusicKit JS release?
Is there any sign of an update to MusicKit JS? The 1.x version still seems to be the only one available despite updates to the iOS and MacOS SDKs. The 1.x version has been fairly unreliable for me and I've paused updates to Apple Music support in my app in hopes that a better version is coming soon.
Replies
4
Boosts
0
Views
1.8k
Activity
Jun ’22
adamId not found Music Kit JS
I'm testing out a dynamic song list to be queued up with Music Kit JS. When testing with a few tracks everything seemed to be working fine but then I ran into this error: The Id in question is Nirvana's "Smells Like Teen Spirit". I retrieved this Id through the Apple Music API and I double-checked it to make sure it was correct and it is. This appeared for a few tracks. I used this API endpoint to verify it was correct: https://api.music.apple.com/v1/catalog/us/songs?filter[isrc]=USGF19942501 this one as well: https://api.music.apple.com/v1/catalog/us/songs/483164390 The ISRC matches that Id, and I can see it directly from the apple id as well. Why does this appear? From everything I see that song does exist and I can play it fine on Apple Music, so why can't I play this through the Music Kit JS instance?
Replies
1
Boosts
0
Views
1.3k
Activity
Jun ’22
Music Kit JS Reload Page
I'm trying to figure out if an event gets called whenever I'm streaming with the music kit player and I reload the page. I'm using Chrome and when I reload the page the streaming music stops and says the browser prevented playing without user interaction. Events I have listeners for include: mediaPlaybackError nowPlayingItemDidChange playbackStateDidChange queueIsReady queueItemsDidChange mediaCanPlay Each of these are associated with a console message so I can track when they get called. This is what appears in my console when I start a playlist: I thought that the "mediaPlaybackError" would be called but it wasn't, and no other errors seem to pop up. The documentation here: https://developer.apple.com/documentation/musickitjs/musickit/events doesn't really explain much about the events.
Replies
4
Boosts
0
Views
1.3k
Activity
Jun ’22
Apple Music API no more returning "next" pagination
Hi! Since a couple of hours or yesterday, there's no more "next" value for the pagination when retrieving playlist tracks. Only a "meta" with a "total" value. Could you please look at this ASAP? Thank you.
Replies
2
Boosts
0
Views
2.6k
Activity
Jun ’22
How can I get more than 100 songs in the queue from playlist in MusicKit JS?
I'm using MusicKit JS v1, and I've noticed that I can't seem to get playlists with more than 100 songs to shuffle and play past the first 100. The limitation is that the API call made with MusicKit JS default fetch (I'm using the tracks relationship in a playlist) is capped at 100, and I get a 400 error code whenever I try to raise the limit. On the other hand, I can't figure out how to just get the next 100, because I can't seem to get the offset parameter to work correctly in MusicKit JS either. Any recommendations? For reference, something like the below just doesn't work (it only retrieves the first 100 songs or throws an error). await appleMusicState.musicKit.api.playlist(selectedPlaylist.id, {limit: 200}) .then(playlist => { console.log(playlist); }) nor does directly trying to setQueue with the playlist ID await appleMusicState.musicKit.setQueue({playlist: selectedPlaylist.id});
Replies
1
Boosts
0
Views
1.5k
Activity
Jun ’22
Ask user for his Media ID in a B2B app
Hi, I'm developing a B2B web-app which will be only used internally by other businesses that already are subscribed to the Apple Developer Program. This app has to communicate with the MusicKit API. I'd like to know if I can ask those business to create a Media ID from their developer account and insert their Team ID, Key ID and Secret in my app, in order to be able to generate a token. I'd like to do so in order to avoid any possible request rate limit on my account in case I made the app use my Media ID for all their requests. Is it possible or doing so I may violate any Apple license aggreement? I can't find this answer anywhere
Replies
0
Boosts
0
Views
1.1k
Activity
May ’22