首页 > 分享 > 微信小程序添加音效createInnerAudioContext

微信小程序添加音效createInnerAudioContext

可以查看微信小程序api文档中

//添加音效 const innerAudioContext = wx.createInnerAudioContext() innerAudioContext.autoplay = true // 是否自动开始播放,默认为 false innerAudioContext.loop =false // 是否循环播放,默认为 false wx.setInnerAudioOption({ // ios在静音状态下能够正常播放音效 obeyMuteSwitch: false, // 是否遵循系统静音开关,默认为 true。当此参数为 false 时,即使用户打开了静音开关,也能继续发出声音。 success: function(e) { console.log(e) console.log('play success') }, fail: function(e) { console.log(e) console.log('play fail') } }) innerAudioContext.src = '/utils/gold.mp3'; // 音频资源的地址 innerAudioContext.onPlay(() => { // 监听音频播放事件 console.log('开始播放') }) innerAudioContext.onError((res) => { // 监听音频播放错误事件 console.log(res.errMsg) console.log(res.errCode) })

1234567891011121314151617181920212223

相关知识

鲜花店微信小程序制作方法教程
微信小程序识别花草方法步骤 微信小程序怎么识别花草
微信小程序商城嫁接公众号的开通步骤是什么?
【网站项目】鲜花销售微信小程序
三明大田花店微信小程序怎么做?
基于微信小程序的校园鲜花销售系统
花店微信小程序真的有必要做吗? 鲜花门店小程序要怎么做呢?
【微信小程序开发实战项目】——如何制作一个属于自己的花店微信小程序(2)
基于微信小程序的网上花店售卖系统
【全网首发】基于微信小程序的网上花店系统 鲜花销售小程序

网址: 微信小程序添加音效createInnerAudioContext https://m.huajiangbk.com/newsview542570.html

所属分类:花卉
上一篇: 专题—对勾函数f(x)=ax b
下一篇: 涨知识!(a+b)²=a²+2a