Điều này khiến tôi phát điên. Đây là mã tôi sử dụng để thiết lập thời gian hiện tại:Tôi có thể tải audio.currentTime nhưng không đặt nó (trong Google Chrome)
$("#audio").click(function(e) {
e.preventDefault();
mr_waveform_skip(e)
});
function mr_waveform_skip(event) {
clientX = event.clientX;
left = event.currentTarget.offsetLeft;
clickoffset = clientX - left;
percent = clickoffset/event.currentTarget.offsetWidth
audio_duration = audio_element.duration;
duration_seek = percent*audio_duration;
audio_element.currentTime = duration_seek;
// audio_element.currentTime = 10;
console.log('CLICK: ' + duration_seek + ' Element: ' + audio_element + ' CurrentTime: ' + audio_element.currentTime);
}
tôi dường như không thể thiếtaudio_element.currentTime
chỉ được nó!
Và tệ hơn, nó hoạt động trong fireFox! Chrome khởi động lại ở mức 0, bất kể điều gì.
Đây là những gì các mã trên tạo ra trong Firefox console:
CLICK: 63.82905432385121 Element: [object HTMLAudioElement] CurrentTime: 3.849546
Và trong Chrome:
CLICK: 63.82905432385121 Element: [object HTMLAudioElement] CurrentTime: 3.849546
Thấy không? Cùng một! Chúng ta có thể thấy rằng Chromes thấy phần tử âm thanh HTML (vì nó có thể nhận được giá trị). Nếu tôi làm audio_element.currentTime = 10;
nó vẫn không hoạt động (trong Chrome, Firefox trung thành khởi động lại ở mức 10) ..
Thử gọi audio.stop(), sau đó audio.currentTime = 10, sau đó audio.play(). –
Tôi đoán bạn có nghĩa là 'audio.pause()' nhưng có, nó hoạt động ... Trong Firefox. Chrome tiếp tục khởi động lại ở 0: [ – yPhil
Bạn đã thử với codec âm thanh khác? – K3N