小程序wxstartRecord调用中IOS的兼容问题
2019-04-03 15:13:30
如何看待微信公开课小程序热门讨论「小程序wxstartRecord调用中IOS的兼容问题」
摘要:小程序wxstartRecord调用中IOS的兼容问题
展开:我点击一个按钮跳转到一个新页面,在页面初始化的时候,调取wx.startRecord({})安卓是没有问题的,而苹果只有第一次进入的时候会进入success,之后进入都是fail:function(res){//录音失败如果我在页面添加一个按钮点击按钮录音的话,无论多少次都没有问题。点击话筒进入苹果第一次进的时候进入success之后进入都是失败代码:onLoad:function(){varthatthis;wx.getStorage({key:search,success:function(res){if(res.data){that.setData({history_text:res.data,history_empty:false})}},fail:function(){//没有缓存不显示that.setData({history_empty:true})}})wx.getStorage({key:userInfo,success:function(res){if(res.data.userId){that.setData({userId:res.data.userId})}},fail:function(){//没有缓存不显示that.setData({userId:})}})},onShow:function(){this.mytouchstart();},onHide:function(){//页面关闭wx.stopRecord()},onUnload:function(){//页面关闭wx.stopRecord()},mytouchstart:function(){console.log(1)varthatthis//开始录音。当主动调用wx.stopRecord,//或者录音超过1分钟时自动结束录音,返回录音文件的临时文件路径。//当用户离开小程序时,此接口无法调用。wx.stopRecord()wx.startRecord({success:function(res){console.log(录音成功+JSON.stringify(res));that.setData({voiceButtonName:语音识别,wavetoword:true,rewavetoword:true,recordingfailed:true,unrecognized:true,acousticwave:true,ensure:true,uploadfailed:true,wavewait:false,voicePlayButtonName:开始播放,tempFilePath:res.tempFilePath})//上传语音文件至服务器wx.uploadFile({url:http://test2,filePath:res.tempFilePath,name:file,//header:{},//设置请求的headerformData:{msg:voice},//HTTP请求中其他额外的formdatasuccess:function(res){//successconsole.log(begin);console.log(res.data);varjsonJSON.parse(res.data);console.log(json.result);varjsonResultjson.result;console.log(jsonResult);varitemjsonResultif(!item){that.setData({acousticwave:true,wavewait:true,wavetoword:true,recordingfailed:true,ensure:true,uploadfailed:true,rewavetoword:false,unrecognized:false})}elseif(item){that.setData({val:item,acousticwave:true,recordingfailed:true,unrecognized:true,ensure:false,wavewait:true,uploadfailed:true,rewavetoword:false,wavetoword:false})}},fail:function(err){that.setData({val:item,acousticwave:true,recordingfailed:true,ensure:true,unrecognized:true,wavewait:true,uploadfailed:false,rewavetoword:false,wavetoword:true})//failconsole.log(err);},onVoiceRecordEnd:function(res){console.log(21)},complete:function(){//complete}})},fail:function(res){//录音失败that.setData({voiceButtonName:语音识别,acousticwave:true,wavewait:true,wavetoword:true,rewavetoword:false,uploadfailed:true,ensure:true,recordingfailed:false,unrecognized:true})console.log(录音失败+JSON.stringify(res));}})setTimeout(function(){//结束录音wx.stopRecord()},5000)},mytouchend:function(){wx.stopRecord()}
摘要:小程序wxstartRecord调用中IOS的兼容问题
展开:我点击一个按钮跳转到一个新页面,在页面初始化的时候,调取wx.startRecord({})安卓是没有问题的,而苹果只有第一次进入的时候会进入success,之后进入都是fail:function(res){//录音失败如果我在页面添加一个按钮点击按钮录音的话,无论多少次都没有问题。点击话筒进入苹果第一次进的时候进入success之后进入都是失败代码:onLoad:function(){varthatthis;wx.getStorage({key:search,success:function(res){if(res.data){that.setData({history_text:res.data,history_empty:false})}},fail:function(){//没有缓存不显示that.setData({history_empty:true})}})wx.getStorage({key:userInfo,success:function(res){if(res.data.userId){that.setData({userId:res.data.userId})}},fail:function(){//没有缓存不显示that.setData({userId:})}})},onShow:function(){this.mytouchstart();},onHide:function(){//页面关闭wx.stopRecord()},onUnload:function(){//页面关闭wx.stopRecord()},mytouchstart:function(){console.log(1)varthatthis//开始录音。当主动调用wx.stopRecord,//或者录音超过1分钟时自动结束录音,返回录音文件的临时文件路径。//当用户离开小程序时,此接口无法调用。wx.stopRecord()wx.startRecord({success:function(res){console.log(录音成功+JSON.stringify(res));that.setData({voiceButtonName:语音识别,wavetoword:true,rewavetoword:true,recordingfailed:true,unrecognized:true,acousticwave:true,ensure:true,uploadfailed:true,wavewait:false,voicePlayButtonName:开始播放,tempFilePath:res.tempFilePath})//上传语音文件至服务器wx.uploadFile({url:http://test2,filePath:res.tempFilePath,name:file,//header:{},//设置请求的headerformData:{msg:voice},//HTTP请求中其他额外的formdatasuccess:function(res){//successconsole.log(begin);console.log(res.data);varjsonJSON.parse(res.data);console.log(json.result);varjsonResultjson.result;console.log(jsonResult);varitemjsonResultif(!item){that.setData({acousticwave:true,wavewait:true,wavetoword:true,recordingfailed:true,ensure:true,uploadfailed:true,rewavetoword:false,unrecognized:false})}elseif(item){that.setData({val:item,acousticwave:true,recordingfailed:true,unrecognized:true,ensure:false,wavewait:true,uploadfailed:true,rewavetoword:false,wavetoword:false})}},fail:function(err){that.setData({val:item,acousticwave:true,recordingfailed:true,ensure:true,unrecognized:true,wavewait:true,uploadfailed:false,rewavetoword:false,wavetoword:true})//failconsole.log(err);},onVoiceRecordEnd:function(res){console.log(21)},complete:function(){//complete}})},fail:function(res){//录音失败that.setData({voiceButtonName:语音识别,acousticwave:true,wavewait:true,wavetoword:true,rewavetoword:false,uploadfailed:true,ensure:true,recordingfailed:false,unrecognized:true})console.log(录音失败+JSON.stringify(res));}})setTimeout(function(){//结束录音wx.stopRecord()},5000)},mytouchend:function(){wx.stopRecord()}
标签:小程序
「小程序wxstartRecord调用中IOS的兼容问题」热门讨论订阅
方法1:微信扫描微信公开课小程序码即可订阅热门讨论「小程序wxstartRecord调用中IOS的兼容问题」
方法2:微信搜索微信公开课小程序名称进入,即可订阅热门讨论「小程序wxstartRecord调用中IOS的兼容问题」
方法3:微信网页访问即速商店,长按识别微信公开课小程序码即可订阅热门讨论「小程序wxstartRecord调用中IOS的兼容问题」
微信公开课小程序热门讨论「小程序wxstartRecord调用中IOS的兼容问题」由微信公开课原创摘录于微信小程序商店shop.jisuapp.cn,转载请注明出处。
微信公开课热门讨论「小程序wxstartRecord调用中IOS的兼容问题」由微信公开课开发者向微信用户提供,并对本服务内容、数据资料及其运营行为等真实性、合法性及有效性承担全部责任。
微信公开课小程序
更新时间:2019-04-03 15:13:30
>
__methodCallerx27;ofundefined
>-404011cloudfunctionexecutionerror
>,请补充选择商家自营-预付卡销售-发行方类目,并在基础信息处申请该类目,通过
>:host在模拟器中显示无效
>:请在小程序服务页面上架正式(非测试)内容或商品后重新提交审核
>.net 微信小程序 上传图片
>'setTimeout'的问题
>‘三朵里熙SPA主题减压空间’为什么搜索关键词‘三朵里‘搜不到
>‘扫普通链接二维码打开小程序‘中设置为体验版,扫码打开是线上版本
>“cloudfunctions**indexjs”gitignore
>“NO ULINK DEVICE FOUND”是怎么回事
>“万马掌上校园”的类目审核
>“上线了”公司开发的微信小程序怎么样?
>“产品是否一定需要条形码”
>