//实现一个计时的录音

blueplay: function () {


var that = this;

var ms = 'modalvoice.m'

var ss = 'modalvoice.s'

that.setData({

time: 1,

[ms]: 0,

[ss]: 0,

})

this.recorderManager = wx.getRecorderManager();


this.recorderManager.onStart(function () {

// 录音开始的回调处理

var interval= setInterval(function () {

var time = that.data.time;

console.log(time)

if (time === 2) {

clearInterval(interval);

}else{

var m = that.data.modalvoice.m

var s = that.data.modalvoice.s

var ms = 'modalvoice.m'

var ss = 'modalvoice.s'

if(s!==60){

console.log(m);

that.setData({

[ms]: m,

[ss]: s+1

})

}else{

that.setData({

[ms]: m+1,

[ss]: 0,

})

}

}

}, 1000);

});

this.recorderManager.onStop(function (res) {

// 停止录音之后,把录取到的音频放在res.tempFilePath

var obj = {

bindtap: "middleplay",

src: '../../image/blue.png',

index: res.tempFilePath

};

that.data.middle.push(obj)


var middle = that.data.middle;

that.setData({

middle: middle

});

var time = that.data.time;

console.log(time)

});

const options = {

sampleRate: 44100,

numberOfChannels: 1,

encodeBitRate: 192000,

format: 'mp3',

frameSize: 50

}

this.recorderManager.start(options);

//modal

var hide = that.data.hidden;

that.setData({

hidden:false

})

},


展开全部
收起
2回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • 三层楼

    18人对此回答表示赞同

    麻烦给个相关的代码片段,我们定位下问题

    展开
    18
    1回复
    发布于 6年前

    评论(1)

    收起评论

    • Tabitha 2019-02-11 12:31

      好了,不知道什么时候录音权限关了

      回复
  • luyishisan13

    11人对此回答表示赞同

    展开
    11
    0回复
    发布于 6年前

    评论(0)

    收起评论

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部