添加校准声音
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
const audioFils = {
|
||||
激光已校准:
|
||||
"https://static.shelingxingqiu.com/attachment/2025-10-29/ddupaur1vdkyhzaqdc.mp3",
|
||||
胜利: "https://static.shelingxingqiu.com/attachment/2025-09-17/dcuo9yjp0kt5msvmvd.mp3",
|
||||
失败: "https://static.shelingxingqiu.com/attachment/2025-09-17/dcuo9yht2sdwhuqygy.mp3",
|
||||
请射箭测试距离:
|
||||
@@ -64,9 +66,9 @@ function debugLog(...args) {
|
||||
// 获取当前环境信息
|
||||
const accountInfo = uni.getAccountInfoSync();
|
||||
const envVersion = accountInfo.miniProgram.envVersion;
|
||||
|
||||
|
||||
// 只在体验版打印日志,正式版(release)和开发版(develop)不打印
|
||||
if (envVersion === 'trial') {
|
||||
if (envVersion === "trial") {
|
||||
console.log(...args);
|
||||
}
|
||||
}
|
||||
@@ -77,13 +79,13 @@ class AudioManager {
|
||||
this.currentPlayingKey = null;
|
||||
this.retryCount = new Map();
|
||||
this.maxRetries = 3;
|
||||
|
||||
|
||||
// 串行加载相关属性
|
||||
this.audioKeys = [];
|
||||
this.currentLoadingIndex = 0;
|
||||
this.isLoading = false;
|
||||
this.loadingPromise = null;
|
||||
|
||||
|
||||
this.initAudios();
|
||||
}
|
||||
|
||||
@@ -98,11 +100,11 @@ class AudioManager {
|
||||
this.isLoading = true;
|
||||
this.audioKeys = Object.keys(audioFils);
|
||||
this.currentLoadingIndex = 0;
|
||||
|
||||
|
||||
this.loadingPromise = new Promise((resolve) => {
|
||||
this.loadNextAudio(resolve);
|
||||
});
|
||||
|
||||
|
||||
return this.loadingPromise;
|
||||
}
|
||||
|
||||
@@ -116,8 +118,12 @@ class AudioManager {
|
||||
}
|
||||
|
||||
const key = this.audioKeys[this.currentLoadingIndex];
|
||||
debugLog(`开始加载音频 ${this.currentLoadingIndex + 1}/${this.audioKeys.length}: ${key}`);
|
||||
|
||||
debugLog(
|
||||
`开始加载音频 ${this.currentLoadingIndex + 1}/${
|
||||
this.audioKeys.length
|
||||
}: ${key}`
|
||||
);
|
||||
|
||||
this.createAudio(key, () => {
|
||||
this.currentLoadingIndex++;
|
||||
setTimeout(() => {
|
||||
@@ -182,12 +188,14 @@ class AudioManager {
|
||||
if (currentRetries < this.maxRetries) {
|
||||
this.retryCount.set(key, currentRetries + 1);
|
||||
debugLog(`音频 ${key} 开始第 ${currentRetries + 1} 次重试...`);
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
this.retryLoadAudio(key);
|
||||
}, 1000);
|
||||
} else {
|
||||
console.error(`音频 ${key} 重试 ${this.maxRetries} 次后仍然失败,停止重试`);
|
||||
console.error(
|
||||
`音频 ${key} 重试 ${this.maxRetries} 次后仍然失败,停止重试`
|
||||
);
|
||||
const failedAudio = this.audioMap.get(key);
|
||||
if (failedAudio) {
|
||||
failedAudio.destroy();
|
||||
|
||||
Reference in New Issue
Block a user