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)