uniapp调用音频
button点击
<view><button @click="startPlay">开始播放</button></view>
方法实现
startPlay() { const innerAudioContext = uni.createInnerAudioContext();innerAudioContext.src = '/static/sounds/oqc.mp3';innerAudioContext.play()}
自定义播放 本地调试可以 打包 APK调用失败(需补充使用)
startPlay() { this.a(); // 开始播放的入口 }, a(){var time = new Date();console.log('time:',time)const asd = '请001号前来办理业务'const msg = new SpeechSynthesisUtterance()msg.text = asdlet that = thismsg.onend = function(){that.count+=1// alert('播放结束')setTimeout(function(){that.play()},1000)}window.speechSynthesis.speak(msg)},play(){console.log('this.count',this.count)if(this.count < 3){this.a()}else{this.count = 0console.log('播放完毕')}// setInterval(this.cyclePlay(),1000)},