I am facing this problem in a chrome browser. When I click on any audio, it throws an exception. My audio tag is in a loop, and when I click on the audio or refresh it using ajax, then the exception is thrown.
I am facing this problem in a chrome browser. When I click on any audio, it throws an exception. My audio tag is in a loop, and when I click on the audio or refresh it using ajax, then the exception is thrown.
Share edited May 11, 2016 at 13:01 zlog 3,3165 gold badges43 silver badges82 bronze badges asked May 10, 2016 at 10:38 vikas palvikas pal 751 silver badge9 bronze badges3 Answers
Reset to default 2I don't know if this will help you, but I still leave my ment so maybe it will help somebody else. I had similar issue, and the solution proposed by @dighan on bountysource./issues/ solved it for me.
So here is the code that solved my problem:
var media = document.getElementById("YourVideo");
const playPromise = media.play();
if (playPromise !== null){
playPromise.catch(() => { media.play(); })
}
Just add it in document.ready
It still throws an error into console, but at least the video is playing :) I think this should work for audio as well.
I got the same error when my media
wasn't loaded. Check these:
- Your
media
has the correctsrc
. - Your
media
is loaded before you play it.
I've recently noticed this happening on one of my sites that had no problems before, and hasn't been changed at all. It appears to be a known bug in Chrome -- take a look at the issue tracker here: https://bugs.chromium/p/chromium/issues/detail?id=593273
It seems that there is no way to prevent the error until this is fixed by the Chrome team.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744814502a4595241.html
评论列表(0条)