INVALID_STATE_ERR: DOM Exception 11 (WebKit)

Viewed 76718

I recently tested a Cappuccino app I was working on with Chrome and Safari. I get the error:

INVALID_STATE_ERR: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable.

The lack of information is frustrating. What object and where did I attempt to use it? Chrome tries to answer the second question but the line number it gives, 465, doesn't mean anything when the file it gives is just 94 lines long. Without more information I don't even know where to start looking.

11 Answers

This problem occured for me because I used the Audio API like this:

let someAudio = new Audio(file);
someAudio.play();
someAudio.pause();

But this is not correct because the play() function is async. Instead you need to use the then function of the returned Promise.

someAudio.play().then(() => someAudio.pause());

Return value: A Promise which is fulfilled when playback has been started, or is rejected if for any reason playback cannot be started. MDN

Related