wx.config({
debug : false,
appId : data.appid,
timestamp : data.timestamp,
nonceStr : data.noncestr,
signature : data.signature,
jsApiList : [ "startRecord", "stopRecord","onVoiceRecordEnd","uploadVoice","downloadVoice","getLocation" ]
});
wx.ready(function() {
startRecord();
wx.onVoiceRecordEnd({
// 录音时间超过一分钟没有停止的时候会执行 complete 回调
complete: function (res) {
var localId = res.localId;
uploadVoice(localId);
setTime=setTimeout(function () {
// 这里就是处理的事件
startRecord(1);
}, 2000);
},
fail : function(res) {
var content=JSON.stringify(res);
console.log(content);
}
});
});
function startRecord() {
wx.startRecord({
success: function(res){
localStorage.rainAllowRecord = 'true';
},
cancel: function () {
saveLog("用户拒绝授权录音");
},
fail : function(res) {
var content=JSON.stringify(res);
saveLog(content);
}
})
// }
}
function uploadVoice(localId) {
wx.uploadVoice({
localId: localId, // 需要上传的音频的本地ID,由stopRecord接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
success: function (res) {
var mediaId=res.serverId;
//把录音在微信服务器上的id(res.serverId)发送到自己的服务器供下载。
$.ajax({
url: '/wx/savefile',
type: 'post',
data: {mediaId:mediaId},
dataType: "json",
success: function (data) {
console.log("文件已保存");
},
error: function (xhr, errorType, error) {
}
});
},
fail : function(res) {
var content=JSON.stringify(res);
saveLog(content);
}
});
}
localID:SbD1jda0oZGqcv375TXBhPfL-0NVU0S6C1QMWXBDUTUr82b7gMYJ462nMUfc-PFx localID:3JUfZFOpfPUIN64GuZRJ3BrcO41pY5tBmWerpBnRCaoeTI4NZaUTSt_vg8iAPWFP
获取到的两段localID都不一致,通过http://api.weixin.qq.com/cgi-bin/media/get?access_token=
获取临时素材下载录音后,听取到的录音内容一致,请问该如何解决
Huawei Mate 9,EMUI 9.1.0,微信版本号8.0.10