Initial commit
This commit is contained in:
26
miniprogram/app.js
Normal file
26
miniprogram/app.js
Normal file
@@ -0,0 +1,26 @@
|
||||
App({
|
||||
onLaunch() {
|
||||
// 初始化音效上下文
|
||||
this.globalData.audioContexts = {
|
||||
flip: wx.createInnerAudioContext(),
|
||||
success: wx.createInnerAudioContext()
|
||||
};
|
||||
|
||||
// 预设音效资源 (用户可替换为本地或云端 URL)
|
||||
// 示例使用了一些开源的基础音效,仅作占位参考
|
||||
this.globalData.audioContexts.flip.src = 'https://assets.mixkit.co/active_storage/sfx/2571/2571-preview.mp3'; // 类似翻页声
|
||||
this.globalData.audioContexts.success.src = 'https://assets.mixkit.co/active_storage/sfx/2000/2000-preview.mp3'; // 类似轻微铃声
|
||||
},
|
||||
|
||||
playAudio(type) {
|
||||
const ctx = this.globalData.audioContexts[type];
|
||||
if (ctx) {
|
||||
ctx.stop();
|
||||
ctx.play();
|
||||
}
|
||||
},
|
||||
|
||||
globalData: {
|
||||
audioContexts: {}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user