在调用.play()
之前设置.currentTime
的HTMLMediaElement
内的canplay
事件pause
事件被调度。如何在canplay事件中设置HTMLMediaElement的.currentTime,调用play并避免调度暂停事件?
当试图设置.currentTime
和错误之后canplay
事件中调用.play()
抛出
DOMException: The play() request was interrupted by a call to pause().
如何设置内部canplay
.currentTime
或HTMLMediaElement
canplaythrough
事件,而不调度pause
事件,或如何从pause
事件处理程序中调用.play()
以启动medi一组播放.currentTime
?
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<video preload="auto" controls></video>
<span></span>
<script>
const url = "https://mirrors.creativecommons.org/movingimages/webm/ScienceCommonsJesseDylan_240p.webm#t=10,15";
const video = document.querySelector("video");
let cursor = 10.5;
video.oncanplay = e => {
video.oncanplay = null;
video.currentTime = cursor;
console.log(e, video.currentTime, video.buffered.end(0));
video.play().catch(err => document.querySelector("span").textContent = err.message);
}
video.onpause = e => {
console.log(e, video.currentTime);
}
video.src = url;
</script>
</body>
</html>
这是值得的,我有* FFmpegVideoDecoder:avcodec_decode_video2():处理输入时发现无效数据,时间戳:10009000持续时间:41000大小:502 side_data_size:0 is_key_frame:0加密:0 discard_padding(ms): (0,0)*在chrome:// media-internals中。 – Kaiido
铬问题https://bugs.chromium.org/p/chromium/issues/detail?id=767163 – guest271314