admin管理员组文章数量:1026423
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;
The error looks like:
SCRIPT5022: InvalidStateError
This script works good in Chrome and Firefox. According to this page it is should work.
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;
The error looks like:
SCRIPT5022: InvalidStateError
This script works good in Chrome and Firefox. According to this page it is should work.
Share Improve this question asked Nov 27, 2013 at 14:32 user2998173user2998173 3472 gold badges6 silver badges10 bronze badges 1- 3 Since IE doesn't really support anything properly, the fastest solution I came up with was putting a try/catch on my audio function. IE users shouldn't be allowed to have sound if they still use this browser... – Jester Commented Feb 6, 2018 at 21:25
3 Answers
Reset to default 23I know this question is old but I just encountered the same problem and wanted to post what I learned.
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.
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
In IE11, this error occurs while accessing the currentTime
attribute of video before the meta data of video is loaded. So following code solved my error.
vidEl.addEventListener('loadedmetadata', function() {
vidEl.currentTime = someSeekTime;
}, false);
Hope this helps someone.
Just wanted to add that converting the Wav file to MP3 solved the issue for me. Using https://stackoverflow.com/a/20462684/5053952 prevented the error but the Wav file still would not play. Converting to MP3 solved the issue completely.
(IE11 on Win10)
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;
The error looks like:
SCRIPT5022: InvalidStateError
This script works good in Chrome and Firefox. According to this page it is should work.
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;
The error looks like:
SCRIPT5022: InvalidStateError
This script works good in Chrome and Firefox. According to this page it is should work.
Share Improve this question asked Nov 27, 2013 at 14:32 user2998173user2998173 3472 gold badges6 silver badges10 bronze badges 1- 3 Since IE doesn't really support anything properly, the fastest solution I came up with was putting a try/catch on my audio function. IE users shouldn't be allowed to have sound if they still use this browser... – Jester Commented Feb 6, 2018 at 21:25
3 Answers
Reset to default 23I know this question is old but I just encountered the same problem and wanted to post what I learned.
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.
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
In IE11, this error occurs while accessing the currentTime
attribute of video before the meta data of video is loaded. So following code solved my error.
vidEl.addEventListener('loadedmetadata', function() {
vidEl.currentTime = someSeekTime;
}, false);
Hope this helps someone.
Just wanted to add that converting the Wav file to MP3 solved the issue for me. Using https://stackoverflow.com/a/20462684/5053952 prevented the error but the Wav file still would not play. Converting to MP3 solved the issue completely.
(IE11 on Win10)
本文标签: javascriptaudiocurrentTime invalidStateError IE11JSHTML5Stack Overflow
版权声明:本文标题:javascript - audio.currentTime invalidStateError IE11, JS, HTML5 - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1738057068a1542240.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论