Ternyata JQUERY itu bisa memainkan file MP3 dari web loh. Yuk kita bikin kodenya
1. Include JQUERY
2. Buat kode nya
<script>
$(document).ready(function() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'audio.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
$( ".status" ).text( "PLAY" );
$.get();
audioElement.addEventListener("load", function() {
audioElement.play();
}, false);
$('.play').click(function() {
audioElement.play();
$( ".status" ).text( "PLAY" );
});
$('.pause').click(function() {
audioElement.pause();
$( ".status" ).text( "PAUSE" );
});
});
</script>
3. Lalu buat tag HTML untuk membuat Play dan Pause serta status playernya
<div class="play"><img src="play.png"></div>
<div class="pause"><img src="pause.png"></div>
<p class="status"></p>
Sekarang improvisasi lah membuat player .
0 Response to "JQUERY Memainkan File audio MP3"
Posting Komentar