小程序
小游戏
企业微信
微信支付
扫描小程序码分享
cocos creator:1.8.2
构建项目:微信小游戏
appid:wx58dad8229ee2b6a1
仿跳一跳的小游戏,在脚本组件属性中定义cc.AudioClip,在属性检查器中将音效文件拖到对应属性上,在代码中使用cc.audioEngine.play(this.audio, false, 1)播放音效。
构建出微信小游戏,预览扫码进入游戏,刚开始玩,音效还正常播放,玩一会就没声音了,console也没有任何报错信息,有人遇到过类似问题吗?
已发布,大家可以看一下
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
用这个wx.createInnerAudioContext()吗?我用以下代码,根本播放不了音效,也没有err信息
目录结构:-audio -success.mp3-script -myScript.js
//myScript.js
onLoad () {
if
(cc.sys.platform === cc.sys.WECHAT_GAME){
cc.innerAudioContext = wx.createInnerAudioContext();
cc.innerAudioContext.volume = 1;
cc.innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
});
}
},
...
//需要播放的时候
cc.innerAudioContext.src =
'../audio/success.mp3'
;
cc.innerAudioContext.play();
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
可以先调用微信提供的播放声音接口看看
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
用这个wx.createInnerAudioContext()吗?我用以下代码,根本播放不了音效,也没有err信息
目录结构:
-audio
-success.mp3
-script
-myScript.js
//myScript.js
onLoad () {
if
(cc.sys.platform === cc.sys.WECHAT_GAME){
cc.innerAudioContext = wx.createInnerAudioContext();
cc.innerAudioContext.volume = 1;
cc.innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
});
}
},
...
//需要播放的时候
if
(cc.sys.platform === cc.sys.WECHAT_GAME){
cc.innerAudioContext.src =
'../audio/success.mp3'
;
cc.innerAudioContext.play();
}
可以先调用微信提供的播放声音接口看看