JavaScript音频播放器,需要在进度条上寻找

时间:2012-09-07 11:54:07

标签: javascript audio seekbar

我有一些代码,其中进度条链接到音频付费;但我还没有弄清楚如何用进度条上的鼠标光标寻找。有没有办法在Legacy JavaScript中执行此操作?

JavaScript的:

function play() {
    document.getElementById('player').play();
}

function pause() {
    document.getElementById('player').pause();
}
function updateProgress() {
    var player = document.getElementById('player');
    var progressbar = document.getElementById('seekbar');
    progressbar.value = (player .currentTime / player .duration);
};

HTML:

<audio ontimeupdate="updateProgress()" src="music/fiji/lladep/apathy.mp3" id="player"></audio>  
<button onClick="play()">Play</button>
<button onClick="pause()">Pause</button>
<progress id="seekbar" value="0" max="1"></progress>

0 个答案:

没有答案