Files
shoot-miniprograms/src/audioManager.js

96 lines
3.3 KiB
JavaScript
Raw Normal View History

2025-07-14 16:37:56 +08:00
const audioFils = {
第一轮:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fl26qrspvy79.mp3",
2025-07-14 16:37:56 +08:00
第二轮:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fehshrpe5ook.mp3",
2025-07-14 16:37:56 +08:00
第三轮:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fgbz3iimk7yy.mp3",
2025-07-14 16:37:56 +08:00
第四轮:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fjwf50tlxxbi.mp3",
2025-07-14 16:37:56 +08:00
第五轮:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fg63lqrslhm7.mp3",
2025-07-14 16:37:56 +08:00
决金箭轮:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fhjycwubbwil.mp3",
2025-07-14 16:37:56 +08:00
请蓝方射击:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fr0zpluiabph.mp3",
2025-07-14 16:37:56 +08:00
请红方射击:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fu169yerpwey.mp3",
2025-07-14 16:37:56 +08:00
中场休息:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblu6fug8faqrbtwd.mp3",
2025-07-14 16:37:56 +08:00
比赛结束:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblsdl717ilr0b3o0.mp3",
2025-07-14 16:37:56 +08:00
比赛开始:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbblsdl7qlkqgvthfr.mp3",
2025-07-14 16:37:56 +08:00
请开始射击:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbljrfx5guqt5oulk.mp3",
2025-07-14 16:37:56 +08:00
未上靶:
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbkxm60bul0khcoqq.mp3",
2025-07-14 16:37:56 +08:00
"1环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbklufj59qmdo96ha.mp3",
2025-07-14 16:37:56 +08:00
"2环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbklufogy49ousbv4.mp3",
2025-07-14 16:37:56 +08:00
"3环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbklufl3hhijeasck.mp3",
2025-07-14 16:37:56 +08:00
"4环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbklufo8vo7k6jxdz.mp3",
2025-07-14 16:37:56 +08:00
"5环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbklkzq7lrbfpr6ij.mp3",
2025-07-14 16:37:56 +08:00
"6环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbkll0fw7hbmmhxkl.mp3",
2025-07-14 16:37:56 +08:00
"7环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbkll0fkirkanghmf.mp3",
2025-07-14 16:37:56 +08:00
"8环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbkll0cly2noykieg.mp3",
2025-07-14 16:37:56 +08:00
"9环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbkll0gsuumekhpkn.mp3",
2025-07-14 16:37:56 +08:00
"10环":
2025-08-04 18:36:44 +08:00
"https://static.shelingxingqiu.com/attachment/2025-07-14/dbbklgw2dk22ek7qha.mp3",
2025-08-26 18:00:40 +08:00
射击无效:
"https://static.shelingxingqiu.com/attachment/2025-08-26/dcc9qc84rir8gkj3mo.mp3",
2025-07-14 16:37:56 +08:00
};
class AudioManager {
constructor() {
this.audioMap = new Map();
Object.keys(audioFils).forEach((key) => {
const audio = uni.createInnerAudioContext();
audio.src = audioFils[key];
audio.autoplay = false;
// 监听加载状态
audio.onCanplay(() => {
2025-07-17 13:55:04 +08:00
// console.log(`音频 ${key} 已加载完成`);
2025-07-14 16:37:56 +08:00
});
audio.onError((res) => {
console.log(`音频 ${key} 加载失败:`, res.errMsg);
});
this.audioMap.set(key, audio);
});
}
// 播放指定音频
play(key) {
const audio = this.audioMap.get(key);
if (audio) audio.play();
}
// 停止指定音频
stop(key) {
const audio = this.audioMap.get(key);
if (audio) audio.stop();
}
// 销毁所有音频实例
destroyAll() {
this.audioMap.forEach((audio) => {
audio.destroy();
});
this.audioMap.clear();
}
}
// 导出单例
export default new AudioManager();