Catch all audio elements.
This commit is contained in:
parent
58e2b0c39d
commit
777ebed7d3
24
game/game.js
24
game/game.js
|
@ -8112,10 +8112,8 @@
|
||||||
ui.backgroundMusic.pause();
|
ui.backgroundMusic.pause();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.addEventListener("resume", function(){
|
document.addEventListener("resume", ()=>{
|
||||||
if(ui.backgroundMusic){
|
if(ui.backgroundMusic) Promise.resolve(ui.backgroundMusic.play()).catch(()=>void 0);
|
||||||
ui.backgroundMusic.play();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
document.addEventListener("backbutton", function(){
|
document.addEventListener("backbutton", function(){
|
||||||
if(ui.arena&&ui.arena.classList.contains('menupaused')){
|
if(ui.arena&&ui.arena.classList.contains('menupaused')){
|
||||||
|
@ -11206,10 +11204,7 @@
|
||||||
game.resume();
|
game.resume();
|
||||||
_status.imchoosing=false;
|
_status.imchoosing=false;
|
||||||
if(roundmenu) ui.roundmenu.style.display='';
|
if(roundmenu) ui.roundmenu.style.display='';
|
||||||
if(ui.backgroundMusic){
|
if(ui.backgroundMusic) Promise.resolve(ui.backgroundMusic.play()).catch(()=>void 0);
|
||||||
var promise=ui.backgroundMusic.play();
|
|
||||||
if(promise) promise.catch(()=>void 0);
|
|
||||||
}
|
|
||||||
hitsound_audio.remove();
|
hitsound_audio.remove();
|
||||||
},1000);
|
},1000);
|
||||||
};
|
};
|
||||||
|
@ -11324,7 +11319,7 @@
|
||||||
combo++;
|
combo++;
|
||||||
max_combo=Math.max(combo,max_combo);
|
max_combo=Math.max(combo,max_combo);
|
||||||
hitsound_audio.currentTime=0;
|
hitsound_audio.currentTime=0;
|
||||||
if(hitsound_audio.paused) hitsound_audio.play();
|
if(hitsound_audio.paused) Promise.resolve(hitsound_audio.play()).catch(()=>void 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -11398,10 +11393,7 @@
|
||||||
if(dialog){
|
if(dialog){
|
||||||
dialog.close();
|
dialog.close();
|
||||||
}
|
}
|
||||||
if(ui.backgroundMusic){
|
if(ui.backgroundMusic) Promise.resolve(ui.backgroundMusic.play()).catch(()=>void 0);
|
||||||
var promise=ui.backgroundMusic.play();
|
|
||||||
if(promise) promise.catch(()=>void 0);
|
|
||||||
}
|
|
||||||
},event.videoId,event.time);
|
},event.videoId,event.time);
|
||||||
var result=event.result||result;
|
var result=event.result||result;
|
||||||
event.result=result;
|
event.result=result;
|
||||||
|
@ -31998,7 +31990,7 @@
|
||||||
};
|
};
|
||||||
//Some browsers do not support "autoplay", so "oncanplay" listening has been added
|
//Some browsers do not support "autoplay", so "oncanplay" listening has been added
|
||||||
audio.oncanplay=function(){
|
audio.oncanplay=function(){
|
||||||
this.play();
|
Promise.resolve(this.play()).catch(()=>void 0);
|
||||||
};
|
};
|
||||||
ui.window.appendChild(audio);
|
ui.window.appendChild(audio);
|
||||||
return audio;
|
return audio;
|
||||||
|
@ -32109,7 +32101,7 @@
|
||||||
};
|
};
|
||||||
//Some browsers do not support "autoplay", so "oncanplay" listening has been added
|
//Some browsers do not support "autoplay", so "oncanplay" listening has been added
|
||||||
audio.oncanplay=function(){
|
audio.oncanplay=function(){
|
||||||
this.play();
|
Promise.resolve(this.play()).catch(()=>void 0);
|
||||||
};
|
};
|
||||||
ui.window.appendChild(audio);
|
ui.window.appendChild(audio);
|
||||||
},
|
},
|
||||||
|
@ -46995,7 +46987,7 @@
|
||||||
ui.window.appendChild(ui.backgroundMusic);
|
ui.window.appendChild(ui.backgroundMusic);
|
||||||
ui.window.addEventListener(lib.config.touchscreen?'touchend':'click', function playMusic() {
|
ui.window.addEventListener(lib.config.touchscreen?'touchend':'click', function playMusic() {
|
||||||
ui.window.removeEventListener(lib.config.touchscreen?'touchend':'click', playMusic, false);
|
ui.window.removeEventListener(lib.config.touchscreen?'touchend':'click', playMusic, false);
|
||||||
if(!ui.backgroundMusic.played.length) ui.backgroundMusic.play();
|
if(!ui.backgroundMusic.played.length) Promise.resolve(ui.backgroundMusic.play()).catch(()=>void 0);
|
||||||
}, false);
|
}, false);
|
||||||
if(lib.config.cursor_style=='pointer'){
|
if(lib.config.cursor_style=='pointer'){
|
||||||
ui.window.classList.add('nopointer');
|
ui.window.classList.add('nopointer');
|
||||||
|
|
Loading…
Reference in New Issue