使用录音功能,每次进入页面,点击开始录音时候,都会提示‘***。要使用你的录音功能,请允许’;这要怎么解决呢
代码:
var time ={ //时长
start:'',
end:''
};
var voice = {
localId: '',
serverId: ''
};
if(!localStorage.rainAllowRecord || localStorage.rainAllowRecord !== 'true'){
wx.startRecord({
success: function(){
wx.stopRecord();
localStorage.rainAllowRecord = 'true';
},
cancel: function () {
wx.stopRecord();
alert('用户拒绝授权录音');
}
});
}
//按下开始录音
$('#startRecord').on('touchstart', function(event){
event.preventDefault();
time.start = new Date().getTime();
recordTimer = setTimeout(function(){
wx.startRecord({
success: function(){
localStorage.rainAllowRecord = 'true';
},
cancel: function () {
alert('用户拒绝授权录音');
}
});
},300);
});
//松手结束录音
$('#startRecord').on('touchend', function(event){
event.preventDefault();
time.end = new Date().getTime();
if((time.end - time.start) < 300){
time.end = 0;
time.start = 0;
//小于300ms,不录音
clearTimeout(recordTimer);
}else{
wx.stopRecord({
success: function (res) {
voice.localId = res.localId;
alert(res.localId);
//panduan(res.localId);
},
fail: function (res) {
alert(JSON.stringify(res)+'123');
}
});
}
});
代码:
var time ={ //时长
start:'',
end:''
};
var voice = {
localId: '',
serverId: ''
};
if(!localStorage.rainAllowRecord || localStorage.rainAllowRecord !== 'true'){
wx.startRecord({
success: function(){
wx.stopRecord();
localStorage.rainAllowRecord = 'true';
},
cancel: function () {
wx.stopRecord();
alert('用户拒绝授权录音');
}
});
}
//按下开始录音
$('#startRecord').on('touchstart', function(event){
event.preventDefault();
time.start = new Date().getTime();
recordTimer = setTimeout(function(){
wx.startRecord({
success: function(){
localStorage.rainAllowRecord = 'true';
},
cancel: function () {
alert('用户拒绝授权录音');
}
});
},300);
});
//松手结束录音
$('#startRecord').on('touchend', function(event){
event.preventDefault();
time.end = new Date().getTime();
if((time.end - time.start) < 300){
time.end = 0;
time.start = 0;
//小于300ms,不录音
clearTimeout(recordTimer);
}else{
wx.stopRecord({
success: function (res) {
voice.localId = res.localId;
alert(res.localId);
//panduan(res.localId);
},
fail: function (res) {
alert(JSON.stringify(res)+'123');
}
});
}
});
解决方案 »
- 关于403 forbidden问题
- PHP+MYSQL插入数据 检查是否重复
- Notice: Undefined offset: 2048 in
- 请帮忙看一下 这个PHP中的函数的静态变量为什么在两次调用中值变了?
- 请教,生成相关的下拉列表
- BOM管理系统
- php下载文件问题
- 数组,字符串查找。谢谢CSDN的兄弟了。
- 递归函数里有foreach数组的时候,数组是怎么被遍历的??
- paypal支付沙盒测试https://www.sandbox.paypal.com/cgi-bin/webscr method="POST只显示空白页面
- SEO网站标题怎么去掉pack 函数
- 如何用php定时把一个mysql数据库的表复制到另一个数据库
wx.startRecord({
success: function(){
wx.stopRecord();
},
cancel: function () {
alert('用户拒绝授权录音');
}
});
});