gpt4 book ai didi

javascript - InvalidStateError : An attempt was made to use an object that is not, 或不再可用

转载 作者:可可西里 更新时间:2023-11-01 02:21:27 24 4
gpt4 key购买 nike

以下适用于 Chrome 但不适用于 Firefox:

var myVideo = document.getElementById('myVideo')
myVideo.currentTime = 570
<video id="myVideo" controls>
<source src="myVideo.mp4" type="video/mp4">
</video>

在 Firefox 中它说

InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable

第 2 行。

最佳答案

当对象(在本例中为视频)加载不足,无法设置 currentTime 并向前跳时,就会发生该错误。

您必须等到视频可以播放后才能设置currentTime

var myVideo = document.getElementById('myVideo')

myVideo.addEventListener('canplaythrough', function() {
myVideo.currentTime = 570;
}, false);

关于javascript - InvalidStateError : An attempt was made to use an object that is not, 或不再可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34970272/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com