Hi guys i tried to do player with playlist but have troubles with Chrome. This code doesn't work in Chrome. I can't understand why, because all another brouser work fine.
<audio id="PlayaBle" src="music/Kalimba.mp3" controls="controls" autoplay="Y">
Your browser does not support HTML5
</audio>
<button id="Next">Next sound</button>
<script>
$(document).ready(function(){
var audio=$('#PlayaBle');
$('#Next').click(function(){
audio.attr('src','music/Sleep Away.mp3')
audio[0].pause();
audio[0].load();
audio[0].play();
});
});
</script>
Errors:
You have space between the src text 'music/Sleep Away.mp3'
;
and code be
var audioElement = document.createElement('audio');
$('#Next').click(function(){
audioElement.pause();
audioElement.setAttribute('src', 'music/Sleep_Away.mp3');
audioElement.addEventListener("load", function() {
audioElement.play();
}, true);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.