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", () => {
|
document.addEventListener("resume", () => {
|
||||||
if (ui.backgroundMusic) ui.backgroundMusic.play();
|
if (ui.backgroundMusic && !isNaN(ui.backgroundMusic.duration)) 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')) {
|
||||||
|
|
|
@ -9050,10 +9050,9 @@ class Create extends Uninstantable {
|
||||||
ui.backgroundMusic.autoplay = true;
|
ui.backgroundMusic.autoplay = true;
|
||||||
ui.backgroundMusic.addEventListener('ended', game.playBackgroundMusic);
|
ui.backgroundMusic.addEventListener('ended', game.playBackgroundMusic);
|
||||||
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', () => {
|
||||||
ui.window.removeEventListener(lib.config.touchscreen ? 'touchend' : 'click', playMusic, false);
|
if (!ui.backgroundMusic.played.length && lib.config.background_music != 'music_off' && !isNaN(ui.backgroundMusic.duration)) ui.backgroundMusic.play();
|
||||||
if (!ui.backgroundMusic.played.length && lib.config.background_music != 'music_off') ui.backgroundMusic.play();
|
}, {once:true});
|
||||||
}, false);
|
|
||||||
if (lib.config.cursor_style == 'pointer') {
|
if (lib.config.cursor_style == 'pointer') {
|
||||||
ui.window.classList.add('nopointer');
|
ui.window.classList.add('nopointer');
|
||||||
}
|
}
|
||||||
|
@ -14142,6 +14141,10 @@ export class UI extends Uninstantable {
|
||||||
* @type { HTMLDivElement }
|
* @type { HTMLDivElement }
|
||||||
*/
|
*/
|
||||||
static pause;
|
static pause;
|
||||||
|
/**
|
||||||
|
* @type { HTMLAudioElement }
|
||||||
|
*/
|
||||||
|
static backgroundMusic;
|
||||||
static refresh(node) {
|
static refresh(node) {
|
||||||
void window.getComputedStyle(node, null).getPropertyValue("opacity");
|
void window.getComputedStyle(node, null).getPropertyValue("opacity");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue