Merge pull request #810 from nonameShijian/PR-Branch
背景音乐在不可播放时不调用play()
This commit is contained in:
commit
842835c521
|
@ -17,7 +17,7 @@ export async function cordovaReady() {
|
|||
}
|
||||
});
|
||||
document.addEventListener("resume", () => {
|
||||
if (ui.backgroundMusic) ui.backgroundMusic.play();
|
||||
if (ui.backgroundMusic && !isNaN(ui.backgroundMusic.duration)) ui.backgroundMusic.play();
|
||||
});
|
||||
document.addEventListener("backbutton", function () {
|
||||
if (ui.arena && ui.arena.classList.contains('menupaused')) {
|
||||
|
|
|
@ -9050,10 +9050,9 @@ class Create extends Uninstantable {
|
|||
ui.backgroundMusic.autoplay = true;
|
||||
ui.backgroundMusic.addEventListener('ended', game.playBackgroundMusic);
|
||||
ui.window.appendChild(ui.backgroundMusic);
|
||||
ui.window.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', function playMusic() {
|
||||
ui.window.removeEventListener(lib.config.touchscreen ? 'touchend' : 'click', playMusic, false);
|
||||
if (!ui.backgroundMusic.played.length && lib.config.background_music != 'music_off') ui.backgroundMusic.play();
|
||||
}, false);
|
||||
ui.window.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', () => {
|
||||
if (!ui.backgroundMusic.played.length && lib.config.background_music != 'music_off' && !isNaN(ui.backgroundMusic.duration)) ui.backgroundMusic.play();
|
||||
}, {once:true});
|
||||
if (lib.config.cursor_style == 'pointer') {
|
||||
ui.window.classList.add('nopointer');
|
||||
}
|
||||
|
@ -14142,6 +14141,10 @@ export class UI extends Uninstantable {
|
|||
* @type { HTMLDivElement }
|
||||
*/
|
||||
static pause;
|
||||
/**
|
||||
* @type { HTMLAudioElement }
|
||||
*/
|
||||
static backgroundMusic;
|
||||
static refresh(node) {
|
||||
void window.getComputedStyle(node, null).getPropertyValue("opacity");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue