admin管理员组文章数量:1122826
I am trying to use Apple's Musickit JS to play songs from Apple Music on a browser.
For some reason this works with some songs but not others in Chrome and Firefox (but it always works in Safari).
So far, I've created my Auth key and managed to allow users to authorise and play a song using Safari, but when using Chrome or Firefox, nothing happens and I don't even get an error message.
I have called in the API and included the "async" and "data-web-components" attributes like so:
<script src=".js" data-web-components async></script>
And my JS that works on Safari is as below:
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 = '';
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();
});
When pressing the play button on Safari, I can see the Audio element appearing at the bottom of the page with the SRC:
<audio id="apple-music-player" preload="metadata" title="Hello, Hi - Little Simz - Hello, Hi - Single" src=".cpsl.aac.wa.m3u8"></audio>
However when using Chrome I am seeing the SRC as something along the lines of:
<audio id="apple-music-player" preload="metadata" title="Hello, Hi - Little Simz - Hello, Hi - Single" src="blob:;></audio>
I can't see any reason why this wouldn't work across the board, and none of the documentation I've seen is offering a solution, so any help is greatly appreciated!
版权声明:本文标题:Apple Musickit JS not playing some songs on Chrome or Firefox browsers (working in Safari) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736281643a1926383.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论