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

Is Apple going to stop people from abusing MusicKit developer token taken from music.apple.com
Many developers know that you can easily get a MusicKit developer token from music.apple.com. Just go to the console of the browser and input "MusicKit.getInstance().developerToken". As of now, the token is eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ.eyJpc3MiOiJBTVBXZWJQbGF5IiwiaWF0IjoxNjQ2NDM1NTgxLCJleHAiOjE2NjE5ODc1ODF9.Ob5bfZBWLDlDkR4r5fNXIjp1Y1G0qY5mP9MVBm1mDFjG701_6AcZS6nwjk-CMJE2b8VLv1JWxKR5j5BDkKxQ7w This token is not like the one we developers generate ourselves that has many limitations. Instead, it is a privileged one that has some powerful features and is able to invoke some "private" API as follows: Deleting users' resources (for example, DELETE method on https://amp-api.music.apple.com/v1/me/library/songs/{id}) Getting and showing lyrics Rename playlist, reordering songs in a playlist Many other features that music.apple.com could do but your apps couldn't I think it's fine to use it privately and do not be evil, but Apple failed to stop people from abusing it. I already spotted one app selling on Microsoft Apps Store(https://apps.microsoft.com/store/detail/cider-alpha/9P21XJ9D9G66) that is taking advantage of this "privileged" token. Proofs are as follows: fetch the privileged developer token https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L3665 removeFromLibrary https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L2254 load official AM lyrics https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L2237 They get the token for free, take the source code from music.apple.com with some modification, put it into an electron app. Then sell it and beat other competitor apps because it's more "powerful". And this makes me a developer obeying the rules like a stupid fool because I pay $99 for ADP to get the developer token, while they get it for free I got a token that has limited features, while theirs are far more powerful I already submitted it to Apple but got no response. Apple should really start to do something, otherwise It's like telling every developer that: Stop paying $99 for ADP to get your developer token, just grab it from music.apple.com. It's free yet super powerful to call private APIs and bypass limitations.
9
0
7.8k
Feb ’23
Apple Music Terms of Use / Guidelines
Hi, I'm working on a web application that uses Apple Music API, but after reading the terms of use and guidelines, it's still shady if what I want to achieve is allowed or not. The core functionality is: users are able to host a "listen party" where everyone can listen to the same song together (using their subscription, no streaming). Just the host can control the music playback. The web app is "freemium". This means that free and paid users can access the same content, there's no paywall. What are the gotchas, in regards to the Terms of Use and Guidelines, when it comes to an app like the one I've just mentioned? What about the copyrights related to the artists/songs? Best Regards, Ricardo
1
0
1.4k
Jan ’23
MusicKit JS v1 token not set in storage
Hello! I'm working to integrate my web application with MusicKit JS. I am experiencing an issue with the authentication flow where the proper localStorage key is not set with the music token after authenticating successfully. The expected output after going through the authentication flow is a localStorage key to be set with a name similar to "music.r4p2h4kf4l.u". I have tested my developer token using a simple HTML file, and after successfully authenticating, the localStorage key is set successfully. My web application that I am developing and experiencing this issue on is built using strapi/reactjs. I have dug into this issue much deeper in the vendor JS code and have possibly narrowed the issue down to immediately after inputting the 6 digit security code. When testing using my simple JS file, a sessionStorage key named "ac" is set to my app's URL (in this example, localhost:3000). When I test using my strapi/react application, this sessionStorage key is not set, and thus I believe this is preventing calls to postMessage and localStorage to not function properly. I have confirmed that when initially opening the auth dialog, the /woa endpoint is called and the referrer parameter is properly set. Does anyone have any idea why this wouldn't work for a reactjs/strapi app? My actual authentication is succeeding and I see a music user token being successfully retrieved in the console within the auth popup. I have spent a lot of time on this and am running out of ideas!
1
0
1.4k
Jan ’23
How to query for an artists latest release using Apple Music API
Hi all - quick question regarding the Apple Music API. I would like to query for an artists most recent album so that I can feature that release more prominently within my app. Looking at the API docs, I could hit an endpoint such as this: https://api.music.apple.com/v1/catalog/us/artists/669831761/albums and that would return all the albums related to that artist. However, it appears that the albums aren't sorted in chronological order, so it seems that I would have to paginate through every page and sort these results to find the most recent release. Is there a better method? I feel like this is a very ineffective practice and would like to hear any possible alternatives, thank you!
2
0
2.1k
Dec ’22
MusicKit playlist creation fails when number of songs is too large
I'm creating a playlist using the MusicKit endpoint and its failing with a generic error when I give it too many songs. [DataRequesting] Failed to perform MusicDataRequest.Context(  url: "https://api.music.apple.com/v1/me/library/playlists",  currentRetryCounts: [.other: 1] ) with MusicDataRequest.Error(  status: 500,  code: 50001,  title: "Upstream Service Error",  detailText: "Service failure: Cloud Library",  id: "NX5X43DEV3KH5NEK3Q7CEHJENM",  originalResponse: MusicDataResponse(   data: 153 bytes,   urlResponse: <NSHTTPURLResponse: 0x0000000280220080>  ) ). I tried setting a maximum of 500 songs and the request succeeded. Is there a known limit to how many songs can be added at once?
1
0
1.9k
Dec ’22
MusicKit Web Components not working
Hi, I noticed in the documentation that v3 supports web components if we pass the data-web-components attr, however this is not the case and no web component is loaded in https://js-cdn.music.apple.com/musickit/v3/musickit.js, should we be using https://js-cdn.music.apple.com/musickit/v3/components/musickit-components/musickit-components.esm.js instead? Thanks
1
1
1.1k
Nov ’22
Playing a song from non-zero starting position
Summary I am trying to play a song starting at a non-zero starting position. For example, I would like to play a song starting at 10 seconds instead of at 0 seconds. Approach setQueue play seekToTime let music = window.MusicKit.getInstance(); // 1: setQueue music.setQueue({ song: "validSongID" }) .then(() = { // 2: play music.player.play() .then(() = { // 3: seekToTime const position = 10; music.player.seekToTime(position); }); }); Expected results The song should start playing at 10 seconds. Actual results ~4 out of every 5 times it works as expected. ~1 out of every 5 times I get the following error: Uncaught (in promise) TypeError: Failed to execute 'remove' on 'SourceBuffer': The end value provided (0) must be greater than the start value provided (0). See also the full error log attached: Error log - https://developer.apple.com/forums/content/attachment/e6252199-17b4-4497-8ee9-d8078cabd7c6 Further Impact The error that is being thrown does not create an mediaPlaybackError event, so I can't even handle the error properly in my application logic.
2
0
1.9k
Nov ’22
Apple Music
hello, I have the latest BETA IOS16 version, I could benefit from the 3-month Apple Music trial offer so I subscribed today and canceled because I had a message telling me that I could take advantage of the offer until January. Except that I no longer have access, do you have a solution or can I benefit from the offer? the goal is to be able to try and potentially subscribe to a definitive package thank!
2
0
1.1k
Oct ’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?
0
0
1.1k
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.3k
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.4k
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.3k
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
924
Jul ’22
Is Apple going to stop people from abusing MusicKit developer token taken from music.apple.com
Many developers know that you can easily get a MusicKit developer token from music.apple.com. Just go to the console of the browser and input "MusicKit.getInstance().developerToken". As of now, the token is eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ.eyJpc3MiOiJBTVBXZWJQbGF5IiwiaWF0IjoxNjQ2NDM1NTgxLCJleHAiOjE2NjE5ODc1ODF9.Ob5bfZBWLDlDkR4r5fNXIjp1Y1G0qY5mP9MVBm1mDFjG701_6AcZS6nwjk-CMJE2b8VLv1JWxKR5j5BDkKxQ7w This token is not like the one we developers generate ourselves that has many limitations. Instead, it is a privileged one that has some powerful features and is able to invoke some "private" API as follows: Deleting users' resources (for example, DELETE method on https://amp-api.music.apple.com/v1/me/library/songs/{id}) Getting and showing lyrics Rename playlist, reordering songs in a playlist Many other features that music.apple.com could do but your apps couldn't I think it's fine to use it privately and do not be evil, but Apple failed to stop people from abusing it. I already spotted one app selling on Microsoft Apps Store(https://apps.microsoft.com/store/detail/cider-alpha/9P21XJ9D9G66) that is taking advantage of this "privileged" token. Proofs are as follows: fetch the privileged developer token https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L3665 removeFromLibrary https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L2254 load official AM lyrics https://github.com/ciderapp/Cider/blob/912a1816de01cbfc55e00a48f187d635d65c0e9c/src/renderer/index.js#L2237 They get the token for free, take the source code from music.apple.com with some modification, put it into an electron app. Then sell it and beat other competitor apps because it's more "powerful". And this makes me a developer obeying the rules like a stupid fool because I pay $99 for ADP to get the developer token, while they get it for free I got a token that has limited features, while theirs are far more powerful I already submitted it to Apple but got no response. Apple should really start to do something, otherwise It's like telling every developer that: Stop paying $99 for ADP to get your developer token, just grab it from music.apple.com. It's free yet super powerful to call private APIs and bypass limitations.
Replies
9
Boosts
0
Views
7.8k
Activity
Feb ’23
Apple Music Terms of Use / Guidelines
Hi, I'm working on a web application that uses Apple Music API, but after reading the terms of use and guidelines, it's still shady if what I want to achieve is allowed or not. The core functionality is: users are able to host a "listen party" where everyone can listen to the same song together (using their subscription, no streaming). Just the host can control the music playback. The web app is "freemium". This means that free and paid users can access the same content, there's no paywall. What are the gotchas, in regards to the Terms of Use and Guidelines, when it comes to an app like the one I've just mentioned? What about the copyrights related to the artists/songs? Best Regards, Ricardo
Replies
1
Boosts
0
Views
1.4k
Activity
Jan ’23
MusicKit JS v1 token not set in storage
Hello! I'm working to integrate my web application with MusicKit JS. I am experiencing an issue with the authentication flow where the proper localStorage key is not set with the music token after authenticating successfully. The expected output after going through the authentication flow is a localStorage key to be set with a name similar to "music.r4p2h4kf4l.u". I have tested my developer token using a simple HTML file, and after successfully authenticating, the localStorage key is set successfully. My web application that I am developing and experiencing this issue on is built using strapi/reactjs. I have dug into this issue much deeper in the vendor JS code and have possibly narrowed the issue down to immediately after inputting the 6 digit security code. When testing using my simple JS file, a sessionStorage key named "ac" is set to my app's URL (in this example, localhost:3000). When I test using my strapi/react application, this sessionStorage key is not set, and thus I believe this is preventing calls to postMessage and localStorage to not function properly. I have confirmed that when initially opening the auth dialog, the /woa endpoint is called and the referrer parameter is properly set. Does anyone have any idea why this wouldn't work for a reactjs/strapi app? My actual authentication is succeeding and I see a music user token being successfully retrieved in the console within the auth popup. I have spent a lot of time on this and am running out of ideas!
Replies
1
Boosts
0
Views
1.4k
Activity
Jan ’23
How to query for an artists latest release using Apple Music API
Hi all - quick question regarding the Apple Music API. I would like to query for an artists most recent album so that I can feature that release more prominently within my app. Looking at the API docs, I could hit an endpoint such as this: https://api.music.apple.com/v1/catalog/us/artists/669831761/albums and that would return all the albums related to that artist. However, it appears that the albums aren't sorted in chronological order, so it seems that I would have to paginate through every page and sort these results to find the most recent release. Is there a better method? I feel like this is a very ineffective practice and would like to hear any possible alternatives, thank you!
Replies
2
Boosts
0
Views
2.1k
Activity
Dec ’22
MusicKit playlist creation fails when number of songs is too large
I'm creating a playlist using the MusicKit endpoint and its failing with a generic error when I give it too many songs. [DataRequesting] Failed to perform MusicDataRequest.Context(  url: "https://api.music.apple.com/v1/me/library/playlists",  currentRetryCounts: [.other: 1] ) with MusicDataRequest.Error(  status: 500,  code: 50001,  title: "Upstream Service Error",  detailText: "Service failure: Cloud Library",  id: "NX5X43DEV3KH5NEK3Q7CEHJENM",  originalResponse: MusicDataResponse(   data: 153 bytes,   urlResponse: <NSHTTPURLResponse: 0x0000000280220080>  ) ). I tried setting a maximum of 500 songs and the request succeeded. Is there a known limit to how many songs can be added at once?
Replies
1
Boosts
0
Views
1.9k
Activity
Dec ’22
MusicKit Web Components not working
Hi, I noticed in the documentation that v3 supports web components if we pass the data-web-components attr, however this is not the case and no web component is loaded in https://js-cdn.music.apple.com/musickit/v3/musickit.js, should we be using https://js-cdn.music.apple.com/musickit/v3/components/musickit-components/musickit-components.esm.js instead? Thanks
Replies
1
Boosts
1
Views
1.1k
Activity
Nov ’22
High-resolution support for MusicKit.JS
I'm very happy that Apple Music now supports lossless audio. However, the applications we have created using MusicKit and MusicKit JS currently do not seem to play in lossless or high-resolution formats. When will we developers be able to use MusicKit and MusicKit JS to play songs in lossless and hi-res formats?
Replies
4
Boosts
2
Views
4.3k
Activity
Nov ’22
Playing a song from non-zero starting position
Summary I am trying to play a song starting at a non-zero starting position. For example, I would like to play a song starting at 10 seconds instead of at 0 seconds. Approach setQueue play seekToTime let music = window.MusicKit.getInstance(); // 1: setQueue music.setQueue({ song: "validSongID" }) .then(() = { // 2: play music.player.play() .then(() = { // 3: seekToTime const position = 10; music.player.seekToTime(position); }); }); Expected results The song should start playing at 10 seconds. Actual results ~4 out of every 5 times it works as expected. ~1 out of every 5 times I get the following error: Uncaught (in promise) TypeError: Failed to execute 'remove' on 'SourceBuffer': The end value provided (0) must be greater than the start value provided (0). See also the full error log attached: Error log - https://developer.apple.com/forums/content/attachment/e6252199-17b4-4497-8ee9-d8078cabd7c6 Further Impact The error that is being thrown does not create an mediaPlaybackError event, so I can't even handle the error properly in my application logic.
Replies
2
Boosts
0
Views
1.9k
Activity
Nov ’22
Apple Music
hello, I have the latest BETA IOS16 version, I could benefit from the 3-month Apple Music trial offer so I subscribed today and canceled because I had a message telling me that I could take advantage of the offer until January. Except that I no longer have access, do you have a solution or can I benefit from the offer? the goal is to be able to try and potentially subscribe to a definitive package thank!
Replies
2
Boosts
0
Views
1.1k
Activity
Oct ’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
1.1k
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.3k
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.4k
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.3k
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.5k
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
924
Activity
Jul ’22