HTML and CSS Reference
In-Depth Information
and the function to toggle play and pause:
function playPause() {
if (audio.paused){
audio.play();
audioPlay.className = 'hidden';
audioPause.className = '';
} else {
audio.pause();
audioPlay.className = '';
audioPause.className = 'hidden';
}
}
Then define the function for the stop, which is based on Recipe 4.2 :
function playStop() {
audio.pause();
audio.currentTime=0;
audioPlay.className = '';
audioPause.className = 'hidden';
}
and the function to format the time for the progress bar:
function timeFormatter(seconds){
function zeroPad(str) {
if (str.length > 2) return str;
for (i=0; i<(2-str.length); i++) {
str = "0" + str;
}
return str;
}
var minute = 60,
hour = minute * 60,
hStr = "",
mStr = "",
sStr = "";
var h = Math.floor(seconds / hour);
hStr = zeroPad(String(h));
var m = Math.floor((seconds - (h * hour)) / minute);
mStr = zeroPad(String(m));
var s = Math.floor((seconds - (h * hour)) - (m * minute));
sStr = zeroPad(String(s));
return (hStr + ":" + mStr + ":" + sStr);
}
</script>
 
Search WWH ::




Custom Search