Answer the question
In order to leave comments, you need to log in
How to fix HTML5 play pause bug in google chrome?
When developing a radio receiver, I ran into a problem in google chrome. It is in chrome, which is the most striking thing, in other browsers everything works fine. There are 2 unknown bugs in chrome. One is obvious, the other is not clear where it came from and even google it does not come out.
First, about the receiver:
radiotune.concord-media.ru
It has station switches - there are about 20 in total. It works on the buzz.js plugin (at first I wanted to do it natively through audio src, but then I started digging on stackoverflow when I found the first one in chrome audio caching bug).
Bug #1:
It's obvious and you could google it. An error was thrown in the console, and playback stopped.
Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().
I found a bug report. What is strange is that it is closed, but apparently the fix was not rolled out in the official update, because I updated chrome a couple of weeks ago, and the branch has been closed for like 8 months. On stackoverflow they offer crutches, such as setTimeout. I don’t know how the rest put jackdaws on it - it didn’t help me personally. Most likely because I have streaming links in src and everything is not so simple with them. Has anyone encountered this bug in practice? How did you fight?
Bug #2:
Already mentioned above. Chrome infection caches the played sound. As a result, after rewinding to the same station, he starts playing what he already cached during the first playback. How to disable this crap, I did not understand. When I tried to do it using native methods (before installing buzz.js), I deleted src in the switching algorithm, then returned it back, set preload none to audio, tried to reset current time to zero and not reset it. Nothing helps.
In general, I am very disappointed in google chrome. Apparently, flash is still relevant because of such jambs, it would seem, the coolest IT company in the world.
UPD
A colleague from the backend suggested to tweak the promise event. I didn’t work with promises and somehow xs how to do it, can someone tell me?
The actual event in its current form:
var i = 0;
switchStationBtn.click(function(){
soundsGroup[i].pause();
if(i === (stations.ids.length - 1)){
i = 0;
}else{
i += 1;
}
});
switchBtn.click(function(){
if(soundsGroup[i].isPaused()){
soundsGroup[i].play();
}else{
soundsGroup[i].pause();
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question