Update:
To add to this, it's now come to my attention that being able to play in Chrome and Firefox depends on the individual track.
Is there a reason why some songs won't play but others will?
For instance, Drake's "Hotline Bling" does work cross browser, but Little Simz's "Hello, Hi" does not.
Post
Replies
Boosts
Views
Activity
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();
});