Post

Replies

Boosts

Views

Activity

Reply to Playing music with Musickit.js in Chrome and Firefox
To add to this, as I know the above link is technically for the old API documentation. Here is my below code, working on Safari, but not Chrome or Firefox. I can see the automatic audio object is loading at the bottom of the screen, but it's not the same assetURL as the Safari browser version. document.addEventListener('musickitloaded', function() { MusicKit.configure({ developerToken: 'MyDeveloperToken', app: { name: 'Apple Music App', build: '1.0.0' } }); }); function playASong() { var music = MusicKit.getInstance(); music.authorize().then(function() { var url = 'https://music.apple.com/gb/album/hotline-bling/1440841363?i=1440841730'; music.setQueue({ url: url }).then(function(queue) { music.player.prepareToPlay(queue.nextPlayableItem).then(function() { music.player.play(); }); }); }); } const playbtn = document.querySelector(".play-button"); playbtn.addEventListener("click", function () { playASong(); });
2w