I'm trying to create a small player using Apple Music Kit JS but I'm having issues when playing the song.
This is my current code:
<html>
<head>
<meta charset=utf-8>
<link rel="shortcut icon" href="#" />
<title>Hear for Mac</title>
</head>
<body>
<script src="https://js-cdn.music.apple.com/musickit/v1/musickit.js"></script>
<script>
const music = MusicKit.configure({
developerToken: 'token', // I put my own token in the real code
app: {
name: 'Hear',
build: '1978.4.1'
}
});
music.authorize().then(function () {
console.log("Authorized");
music.setQueue({
song: '1292397498'
}).then(function () {
music.play();
})
})
window.music = music;
</script>
</body>
</html>
And this is the error I'm getting when it tries playing:
TypeError: Argument 1 ('event') to EventTarget.dispatchEvent must be an instance of Event
you forgot in the script first
In time you are trying to configure MusicKit it is not yet loaded