添加为上靶的方向指示
This commit is contained in:
@@ -109,6 +109,9 @@ class AudioManager {
|
||||
this.sequenceIndex = 0;
|
||||
this.isSequenceRunning = false;
|
||||
|
||||
// 静音开关
|
||||
this.isMuted = false;
|
||||
|
||||
// 网络状态相关
|
||||
this.networkOnline = true;
|
||||
this.pendingPlayKey = null;
|
||||
@@ -176,6 +179,15 @@ class AudioManager {
|
||||
audio.autoplay = false;
|
||||
audio.src = src;
|
||||
|
||||
// 初始化音量(支持的平台用 volume,H5 也可用 muted 作为兜底)
|
||||
try {
|
||||
if (typeof audio.volume === "number") {
|
||||
audio.volume = this.isMuted ? 0 : 1;
|
||||
} else if (typeof audio.muted !== "undefined") {
|
||||
audio.muted = this.isMuted;
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
// 初始化为不允许播放,只有显式 play() 才允许
|
||||
this.allowPlayMap.set(key, false);
|
||||
|
||||
@@ -340,6 +352,14 @@ class AudioManager {
|
||||
|
||||
const audio = this.audioMap.get(key);
|
||||
if (audio) {
|
||||
// 播放前确保遵循当前静音状态
|
||||
try {
|
||||
if (typeof audio.volume === "number") {
|
||||
audio.volume = this.isMuted ? 0 : 1;
|
||||
} else if (typeof audio.muted !== "undefined") {
|
||||
audio.muted = this.isMuted;
|
||||
}
|
||||
} catch (_) {}
|
||||
// 同一音频:避免 stop() 触发 onStop 清除授权,使用 pause()+seek(0)
|
||||
try {
|
||||
audio.pause();
|
||||
@@ -458,6 +478,21 @@ class AudioManager {
|
||||
this.retryLoadAudio(key);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置静音开关:true 静音,false 取消静音
|
||||
setMuted(muted) {
|
||||
this.isMuted = !!muted;
|
||||
for (const audio of this.audioMap.values()) {
|
||||
try {
|
||||
if (typeof audio.volume === "number") {
|
||||
audio.volume = this.isMuted ? 0 : 1;
|
||||
} else if (typeof audio.muted !== "undefined") {
|
||||
audio.muted = this.isMuted;
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
debugLog(`静音状态已设置为: ${this.isMuted}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 导出单例
|
||||
|
||||
Reference in New Issue
Block a user