socket链接播放语音的问题
let loginName = wx.getStorageSync( 'loginName' ); if (!!loginName) { let SocketTask= null ; SocketTask = wx.connectSocket({ url: hosts.wss + '/dahe/servers.html?loginName=' + loginName, header: { 'content-type' : 'application/json' }, method: "GET" , success(res) { console.log( "==================websocket链接返回的数据11:===================" ); console.log(res); } }) SocketTask.onMessage((res) => { console.log( "==================onMessage事件=================" ); console.log(res.data); let params = "content=" + res.data; //语音播报: generateSpeech(params).then(res => { let voiceMus = app.voiceMus; console.log( "=============生成的合成语音地址:=============" ); console.log(res); voiceMus.src = hosts.javaHost + res; console.log( "=============正常播报语音:=============" ); voiceMus.play();//在开发者工具上可以播放语音,在真机上没反应 }); }); SocketTask.onOpen((res) => { console.log( "==================onOpen事件=================" ); console.log(res); }) } |
webSocket状态下,开发者工具上可以正常播放语音,但在真机上无反应,不能播放语音。求解
2 回复
你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。