Position: 0
Total:0
Description:
Seek the position of sound.
Result:
Play with the given position.
Code:
var source = null; // duration is the length of sound, in seconds var duration = null; function onload() { var engine = new jWebAudio.SoundEngine(); source = engine.addSoundSource({ 'url': '../../examples/resource/a.ogg', 'preLoad': true, 'callback': function() { source.sound.play(); duration = source.sound.duration; document.getElementById('totalSpan').innerHTML = Math.ceil(duration); document.getElementById('posInput').disabled = false; // update position 10 times per second setInterval(updatePos, 100); } }); } function posChange() { var pos = Math.min(document.getElementById('posInput') .value / 100 * duration, duration); // set position source.sound.seek(pos); } function updatePos() { var pos = source.sound.offset; document.getElementById('posInput').value = pos / duration * 100; document.getElementById('posSpan').innerHTML = Math.ceil(pos); }