MusicKit JS

RSS for tag

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

Posts under MusicKit JS tag

124 Posts

Post

Replies

Boosts

Views

Activity

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
1.2k
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.6k
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
1.1k
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
2.2k
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
866
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.8k
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
2.1k
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.6k
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.6k
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.8k
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.3k
May ’22
Music Kit Authorize without Subscription
I'm working on a streaming application using Music Kit. For the login, I'm using the "authorize" method which works fine when I use an account that has an Apple Music subscription. When I use an account that does not have a subscription I get prompted to try out Apple Music: If I click "not now" it doesn't return anything at all from what I see and it just stops my function altogether. This is the code I have setup to test this: const appleLogin = async () => {   console.log("Apple Login Called");   const userToken = await appleMusicInstance.value.authorize();   console.log("user token", userToken); }; When I log in using a subscription account it works fine, I get a token and I can stream full-length songs. When I click "not now" (with a non-subscription account) it just stops. Doesn't even show that my "userToken" received anything and nothing else in the function gets called. I'd like to have the ability for members to log in with their account whether they have a subscription or not and play either full length or previews based on their subscription status. What would be the best solution to this?
1
0
2.1k
Apr ’22
Apple Music API no longer working in our app.
Hi, We have an app which is a music social network, it worked fine on both Spotify/Apple Music up until the last few days, now the Apple Music search function is not working at all. Just wondering have we missed something has changed or any idea why it would be returning null. See image. We've tried other apps that use Apple Music and they seem fine, but nothing has changed on our app. So we know the API is working. We're puzzled. Does anyone have any idea, would be massively appreciated.
2
0
1.3k
Mar ’22
MusicKit JS webplayer
I am trying to create a webplayer for apple music and have run into some issues with actually playing the music. authorized.then((res) => { console.log(res); musicInstance.setQueue({ song: '1025212395' }).then((queue) => { console.log(queue) musicInstance.play(); }); },(rej) => { console.log("Failed to Recieve User Authorization") }) where authorized is the promise that is returned when the user logs in. I keep getting the following console errors when attempting to play any sort of media and have no clue how to debug it. Sometimes, it says DOM error and mediasource readyState is not 'open' Any ideas?
1
0
1.3k
Mar ’22
MusicKit JS - Invalid JWT validation
I have a web-app that is recently experiencing problems with users not being able to connect their Apple Music account. It was working perfectly up until now, it may be something with how my dependencies changed but I doubt that. In any case, once I invoke requestUserToken(), the tab is opened, and after authentication they get "Problem Connecting - There may be a network issue." Upon hitting "Try Again" the same error message appears, but this time the URL bar shows something along the lines of "ERROR_FAILED_TO_VERIFY_JWT&pod=10". What can be the reason for this?
5
0
1.7k
Mar ’22
Can MusicKit JS play queue continuously when phone is locked
Though I can get MusicKit JS to play continuously on desktop in the background, the player seems to stop at the end of a track on iPhone even if there are more tracks in the queue. Is this a known limitation? If so, are there any events I can listen to so that the app knows MusicKit has paused playback? If there is a solution I would appreciate any documentation or examples.
1
0
986
Mar ’22
JWT works for Apple Music API but doesn't work for MusicKit
A while ago I started developing a hobby web app aroune Apple Music, and I created a script to generate my JWT and I used it with MusicKit and with Apple Music API and everything was working perfectly fine, and now I came back and wanted to continue the project from where I left off and I tried using the same code (I literally ran the same script without changing anything, it already had the p8 file and the team ID and app key etc..) so I generated a new JWT with that script, and for the Apple Music API it's working as it should, but for the MusicKit (only tried for web) it seems to not work. For some reason when I try to authorize the user (w/ MusicKit for web) it does open the authorization pop up window and after the user enters their Apple Music credentials and tries to login, the pop up windows says there's an error, and in the URL I can see an "error" query param with the value "ERROR_FAILED_TO_VERIFY_JWT" (but the JWT is clearly working fine with Apple Music API...) I already opened an issue report on the feedback assistant, but I was thinking maybe someone has/had the same problem and knows how to solve it or what causes it :)
2
0
2.1k
Mar ’22
Getting editorialVideo from MusicKit Request
Working with MusicKitJS V3, and with the extend key being used, I'm trying to request the animated editorialVideo in my app. this.musicKitInstance.api.music( `v1/catalog/${this.musicKitInstance.storefrontId}/albums/${id}`, { extend: 'artistUrl,composerUrl,trackCount,editorialVideo,editorialArtwork', } ) Looking at how music.apple.com does it, this appears to be the correct format, but the API never returns the editorialVideo in the response. Which stands out as the API will return the artistUrl in the response, just not the editorialVideo. Is this a limitation of the API?
1
0
1.3k
Feb ’22
Could Apple create properly working Recently Played Endpoint?
I already submitted bug by Feedback Assistant. Hopefully, Apple engineers will read this. What is wrong?: Lack of date and time of song's access. Without this it's impossible to scrobble. When I play song using MusicKitJS v1 they are not reflected in history at all. If I play the same song several times in loop endpoint suggests song was played only once. Also there is a mess in documentation. Official page of MusicKit redirects to JS version 3 while Apple Developer Documentation lists MusicKit v1, I assume there was no version 2 and 3 is in beta? Since there is some progress e.g ability to play radio stations in JSv3 it would be nice if main Apple Music API was also updated and finally gaves us ability to delete song from playlist.
0
1
1.1k
Dec ’21
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
1.2k
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.6k
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
1.1k
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
2.2k
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
866
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.8k
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
2.1k
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.6k
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.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.8k
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.3k
Activity
May ’22
Music Kit Authorize without Subscription
I'm working on a streaming application using Music Kit. For the login, I'm using the "authorize" method which works fine when I use an account that has an Apple Music subscription. When I use an account that does not have a subscription I get prompted to try out Apple Music: If I click "not now" it doesn't return anything at all from what I see and it just stops my function altogether. This is the code I have setup to test this: const appleLogin = async () => {   console.log("Apple Login Called");   const userToken = await appleMusicInstance.value.authorize();   console.log("user token", userToken); }; When I log in using a subscription account it works fine, I get a token and I can stream full-length songs. When I click "not now" (with a non-subscription account) it just stops. Doesn't even show that my "userToken" received anything and nothing else in the function gets called. I'd like to have the ability for members to log in with their account whether they have a subscription or not and play either full length or previews based on their subscription status. What would be the best solution to this?
Replies
1
Boosts
0
Views
2.1k
Activity
Apr ’22
Apple Music API no longer working in our app.
Hi, We have an app which is a music social network, it worked fine on both Spotify/Apple Music up until the last few days, now the Apple Music search function is not working at all. Just wondering have we missed something has changed or any idea why it would be returning null. See image. We've tried other apps that use Apple Music and they seem fine, but nothing has changed on our app. So we know the API is working. We're puzzled. Does anyone have any idea, would be massively appreciated.
Replies
2
Boosts
0
Views
1.3k
Activity
Mar ’22
MusicKit JS webplayer
I am trying to create a webplayer for apple music and have run into some issues with actually playing the music. authorized.then((res) => { console.log(res); musicInstance.setQueue({ song: '1025212395' }).then((queue) => { console.log(queue) musicInstance.play(); }); },(rej) => { console.log("Failed to Recieve User Authorization") }) where authorized is the promise that is returned when the user logs in. I keep getting the following console errors when attempting to play any sort of media and have no clue how to debug it. Sometimes, it says DOM error and mediasource readyState is not 'open' Any ideas?
Replies
1
Boosts
0
Views
1.3k
Activity
Mar ’22
MusicKit JS - Invalid JWT validation
I have a web-app that is recently experiencing problems with users not being able to connect their Apple Music account. It was working perfectly up until now, it may be something with how my dependencies changed but I doubt that. In any case, once I invoke requestUserToken(), the tab is opened, and after authentication they get "Problem Connecting - There may be a network issue." Upon hitting "Try Again" the same error message appears, but this time the URL bar shows something along the lines of "ERROR_FAILED_TO_VERIFY_JWT&pod=10". What can be the reason for this?
Replies
5
Boosts
0
Views
1.7k
Activity
Mar ’22
Can MusicKit JS play queue continuously when phone is locked
Though I can get MusicKit JS to play continuously on desktop in the background, the player seems to stop at the end of a track on iPhone even if there are more tracks in the queue. Is this a known limitation? If so, are there any events I can listen to so that the app knows MusicKit has paused playback? If there is a solution I would appreciate any documentation or examples.
Replies
1
Boosts
0
Views
986
Activity
Mar ’22
JWT works for Apple Music API but doesn't work for MusicKit
A while ago I started developing a hobby web app aroune Apple Music, and I created a script to generate my JWT and I used it with MusicKit and with Apple Music API and everything was working perfectly fine, and now I came back and wanted to continue the project from where I left off and I tried using the same code (I literally ran the same script without changing anything, it already had the p8 file and the team ID and app key etc..) so I generated a new JWT with that script, and for the Apple Music API it's working as it should, but for the MusicKit (only tried for web) it seems to not work. For some reason when I try to authorize the user (w/ MusicKit for web) it does open the authorization pop up window and after the user enters their Apple Music credentials and tries to login, the pop up windows says there's an error, and in the URL I can see an "error" query param with the value "ERROR_FAILED_TO_VERIFY_JWT" (but the JWT is clearly working fine with Apple Music API...) I already opened an issue report on the feedback assistant, but I was thinking maybe someone has/had the same problem and knows how to solve it or what causes it :)
Replies
2
Boosts
0
Views
2.1k
Activity
Mar ’22
Getting editorialVideo from MusicKit Request
Working with MusicKitJS V3, and with the extend key being used, I'm trying to request the animated editorialVideo in my app. this.musicKitInstance.api.music( `v1/catalog/${this.musicKitInstance.storefrontId}/albums/${id}`, { extend: 'artistUrl,composerUrl,trackCount,editorialVideo,editorialArtwork', } ) Looking at how music.apple.com does it, this appears to be the correct format, but the API never returns the editorialVideo in the response. Which stands out as the API will return the artistUrl in the response, just not the editorialVideo. Is this a limitation of the API?
Replies
1
Boosts
0
Views
1.3k
Activity
Feb ’22
Could Apple create properly working Recently Played Endpoint?
I already submitted bug by Feedback Assistant. Hopefully, Apple engineers will read this. What is wrong?: Lack of date and time of song's access. Without this it's impossible to scrobble. When I play song using MusicKitJS v1 they are not reflected in history at all. If I play the same song several times in loop endpoint suggests song was played only once. Also there is a mess in documentation. Official page of MusicKit redirects to JS version 3 while Apple Developer Documentation lists MusicKit v1, I assume there was no version 2 and 3 is in beta? Since there is some progress e.g ability to play radio stations in JSv3 it would be nice if main Apple Music API was also updated and finally gaves us ability to delete song from playlist.
Replies
0
Boosts
1
Views
1.1k
Activity
Dec ’21