uniapp 如何调用音频

uniapp调用音频

button点击

powershell 复制代码
       <view>
       <button @click="startPlay">开始播放</button>
       </view>

方法实现

powershell 复制代码
  startPlay() {  
      const innerAudioContext = uni.createInnerAudioContext();
      innerAudioContext.src = '/static/sounds/oqc.mp3';
      innerAudioContext.play()
       }

自定义播放 本地调试可以 打包 APK调用失败(需补充使用)

powershell 复制代码
  startPlay() {  
     this.a(); // 开始播放的入口 
     },  
     a(){

         var time = new Date();
          console.log('time:',time)
          const asd = '请001号前来办理业务'
          const msg = new SpeechSynthesisUtterance()
          msg.text = asd
          let that = this
          msg.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 = 0
            console.log('播放完毕')
          }
          // setInterval(this.cyclePlay(),1000)
        },
相关推荐
沙蒿同学3 小时前
不引 Ghostscript:我用纯 Go 给 PDF 做了一场「压缩手术」
前端·后端·github
变与不变8063 小时前
jQuery细节以及使用应用场景
前端·javascript·jquery
AI视频工具指南4 小时前
怎么用 AI 做悬疑短剧?
人工智能·aigc·音视频
SailingCoder5 小时前
【封闭结束1】端到端交付:Agent 一次请求如何走完全链路
前端·安全·ai·面试·agent·harness
技灵AI6 小时前
AI 口播视频提示词怎么写?让人物讲解和产品展示更自然
人工智能·音视频
企业数字化笔记6 小时前
AI视频增强后画质怎么验收?插值基线、伪细节与帧间闪烁的检查方法
人工智能·算法·音视频
风骏时光牛马7 小时前
AI多模块协同自动化工作流
前端
zhangminghuan7 小时前
前端面试应对技巧
前端·面试·职场和发展
计算机魔术师8 小时前
潜伏14年的PHP致命洞,AI跑两天就交卷了
前端
IT_陈寒8 小时前
Vue的这个响应式陷阱我居然现在才发现
前端·人工智能·后端