audio.currentTime invalidStateError IE11, JS, HTML5

html, internet-explorer, javascript

Solution

I 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

Problem

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.

Original source