audio.currentTime invalidStateError IE11,JS,HTML5 [英] audio.currentTime invalidStateError IE11, JS, HTML5
问题描述
我在IE11中收到此错误,我暂时更改了所有变量只是一个数字,但我无法摆脱这个错误。
I get this error in IE11, i have temporary changed all variables on just a number, but i can't get rid of this error.
audio.currentTime = 10;
错误如下:
SCRIPT5022: InvalidStateError
此脚本在Chrome和Firefox中运行良好。
根据此页它应该可以工作。
This script works good in Chrome and Firefox. According to this page it is should work.
推荐答案
我知道这个问题很老但我刚遇到同样的问题想发帖我学到了什么。
I know this question is old but I just encountered the same problem and wanted to post what I learned.
您的音频播放器是否成功加载了音频?如果src =#或者你给了播放器错误的音频文件路径,那么你提供的代码行就会出现你提到的错误。
Did your audio player successfully load the audio? If the src="#" or if you gave the player the wrong path to the audio file the line of code you provided will give the error you mentioned.
我会建议尝试以下代码,其中audioPlayer是音频元素的id,以执行音频文件确实已加载的简单检查:
I would suggest trying the following code where audioPlayer is the id of the audio element to perform a simple check that the audio file has indeed loaded:
if (!isNaN(aud.duration)) {
aud.currentTime = vid.currentTime;
}
但当然,如果您期望音频已加载,请修复音频文件的路径
But of course, if you're expecting the audio to have loaded, fix the path to the audio file
这篇关于audio.currentTime invalidStateError IE11,JS,HTML5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!