// audioUtils.js let audioContext = null; export function playVoice(url) { if (audioContext) { try { audioContext.pause(); audioContext.destroy(); audioContext = null; } catch (e) { // TODO: Handle the exception } audioContext = uni.createInnerAudioContext(); audioContext.autoplay = true; audioContext.src = url; audioContext.onPlay(() => { console.log('开始播放'); }); } else { audioContext = uni.createInnerAudioContext(); audioContext.autoplay = true; audioContext.src = url; audioContext.onPlay(() => { console.log('开始播放'); }); } } export const audioUrls = { failVoiceUrl: '../../static/fail.mp3', allSuccessVoiceUrl: '../../static/allSuccess.mp3', successVoiceUrl: '../../static/success.mp3', success2VoiceUrl: '../../static/success2.mp3' }