HTML5 audio - testing for Invalid State Error ( Or Dom Exception 11 )

后端 未结 2 785
我寻月下人不归
我寻月下人不归 2021-02-15 16:01

I am dynamically creating a audio file and changing the source on the fly. However after i change the src and try to change the currentTime i always get a Invalid state error. H

2条回答
  •  执念已碎
    2021-02-15 16:45

    For those coming after who actually need a test to prevent this invalid state error, you can try this:

    if(this.readyState > 0)
        this.currentTime = aTime;
    

    Seems to work for me anyways :)

提交回复
热议问题