var RecrodTask = '';
mui('body').on('hold','.voicebtn',function(event){
try {
event.preventDefault();
}catch (e) {
console.log(e);
}
jQuery(this).text('松開 結束');
START = new Date().getTime();
recordTimer = setTimeout(function(){
wx.startRecord({
success: function(){
localStorage.rainAllowRecord = 'true';
}
,cancel: function () {
util.toast("已取消",'', "error");
}
});
},300);
});
mui('body').on('release','.voicebtn',function(event){
try {
event.preventDefault();
}catch (e) {
console.log(e);
}
jQuery(this).text('按住 說話');
END = new Date().getTime();
if((END - START) < 1000){
//小于1000ms,不錄音
util.toast("錄音時間太短", "","error");
END = START = 0;
setTimeout(function(){wx.stopRecord()},800);
clearTimeout(recordTimer);
}else{
wx.stopRecord({
success: function (res) {
voice.localId = res.localId;
var yuyintime = (END - START);
uploadVoice(yuyintime);
clearTimeout(recordTimer);
},
fail: function (res) {
console.log(res);
util.toast("停止錄音動作發生例外(0)","", "error");
clearTimeout(recordTimer);
}
});
}
});
如何實作在小程式中錄音不會出現《停止錄音動作發生例外》的錯誤啊
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/39061.html
標籤:微信開發
下一篇:新手求助label輸出問題
