我想在后臺播放我的網頁上的音樂播放列表,我使用的是 chrome我不需要控制臺,我想要自動播放,但是,盡管我編寫了自動播放,但音頻僅從播放按鈕開始安慰。這就是我在 HTML 中寫的內容:<div id="music_list"> <audio controls autoplay></audio></div>在 JavaScript 中(function () { // Playlist array var files = [ "ms4/14_1.30.mp3", "ms4/20_20.mp3", "ms4/21_34.mp3" ]; // Current index of the files array var i = 0; // Get the audio element var music_player = document.querySelector("#music_list audio"); // function for moving to next audio file function next() { // Check for last audio file in the playlist if (i === files.length - 1) { i = 0; } else { i++; } // Change the audio element source music_player.src = files[i]; } // Check if the player is slected if (music_player === null) { throw "Playlist Player does not exists ..."; } else { // Start the player music_player.src = files[i]; // Listen for the music ended event, to play the next audio file music_player.addEventListener('ended', next, false) }})();我該如何解決這個問題?我對 HTML 和 JS 很陌生,但我陷入了這個問題。
自動播放不適用于我的音樂播放列表
千萬里不及你
2023-08-05 11:51:55