收藏
回答

recorderManager 最多只能录5分钟?


代码如上,每次超过 5 分钟,只能有 5 分钟,模拟器正常,录到10分钟会自动停止。

用了四部真机测试,录制到 9 分多钟会手动停止,都是只能显示 5 分钟。

录音的前一个页面是video组件在播放视频,点击视频下面的发送语音按钮,到新页面录制。




// 开始录制

start: function (e) {

const that = this;

console.log(e);

that.setData({

JGH_recording1: false

})


recorderManager.onStart(() => {

that.isrecordering = true;

})

recorderManager.onStop(function (res) {

let _new_count = formatTime(res.duration / 1000);

let audioData = {};

audioData.audio_url = res.tempFilePath;

audioData.duration = res.duration;

audioData.playstate = 'pause';

audioData.new_duration = _new_count;

that.subaudio(res.tempFilePath, res.duration, audioData);


});


const options = {

duration: 600000,

sampleRate: 44100,

numberOfChannels: 1,

encodeBitRate: 192000,

format: 'mp3',

frameSize: 50

};

recorderManager.start(options);

//时间统计

var totalSecond = 0;

interval = setInterval(function () {

// 秒数  

var second = totalSecond;


// 分钟位  

var min = Math.floor((second) / 60);

var minStr = min.toString();

if (minStr.length == 1) minStr = '0' + minStr;


// 秒位  

var sec = second - min * 60;

var secStr = sec.toString();

if (secStr.length == 1) secStr = '0' + secStr;


that.setData({

totalSecond: totalSecond,

countDownMinute: minStr,

countDownSecond: secStr

});

totalSecond++;

if (totalSecond < 0) {

clearInterval(interval);

//设置结束

that.setData({

totalSecond: totalSecond,

countDownMinute: '00',

countDownSecond: '00'

});

}

}.bind(this), 1000);


},



// 停止录音

stop: function (e) {

const that = this;

recorderManager.stop();

clearInterval(interval);

that.isrecordering = false;

that.setData({

state: 'stop',

countDownMinute: '00',

countDownSecond: '00'

})

that.setData({

JGH_recording1: true

})

},


最后一次编辑于  2019-08-02
回答关注问题邀请回答
收藏

2 个回答

  • 李耀峰
    李耀峰
    2019-08-02

    机型:苹果6p

    微信版本:7.0.5


    设置了最多 10 分钟,实际录制 9 分多钟手动停止,实际录音文件显示只有 5 分钟

    2019-08-02
    有用
    回复
  • 灵芝
    灵芝
    2019-08-02

    你好,是10分钟的,可参考:https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.start.html


    2019-08-02
    有用
    回复 8
    • 李耀峰
      李耀峰
      2019-08-02
      模拟器10分钟没问题,但是真机上,虽然设置了 10 分钟,只能录 5 分钟
      2019-08-02
      回复
    • 李耀峰
      李耀峰
      2019-08-02
      现在问题状态是 已回答 ,这也太仓促了吧
      2019-08-02
      回复
    • 灵芝
      灵芝
      2019-08-02回复李耀峰

      麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

      2019-08-02
      回复
    • 灵芝
      灵芝
      2019-08-02回复李耀峰

      那个已回答是指你评论了这个帖子哈

      2019-08-02
      回复
    • 李耀峰
      李耀峰
      2019-08-02回复灵芝
      机型:苹果6p 微信版本:7.0.5 // 开始录制 start: function (e) { const that = this; console.log(e); that.setData({ JGH_recording1: false }) recorderManager.onStart(() => { that.isrecordering = true; }) recorderManager.onStop(function (res) { let _new_count = formatTime(res.duration / 1000); let audioData = {}; audioData.audio_url = res.tempFilePath; audioData.duration = res.duration; audioData.playstate = 'pause'; audioData.new_duration = _new_count; audioData.play_img = 'http://imgs.52jiaoshi.com/1531100999.png'; that.subaudio(res.tempFilePath, res.duration, audioData); }); const options = { duration: 600000, sampleRate: 44100, numberOfChannels: 1, encodeBitRate: 192000, format: 'mp3', frameSize: 50 }; recorderManager.start(options); //时间统计 var totalSecond = 0; interval = setInterval(function () { // 秒数 var second = totalSecond; // 分钟位 var min = Math.floor((second) / 60); var minStr = min.toString(); if (minStr.length == 1) minStr = '0' + minStr; // 秒位 var sec = second - min * 60; var secStr = sec.toString(); if (secStr.length == 1) secStr = '0' + secStr; that.setData({ totalSecond: totalSecond, countDownMinute: minStr, countDownSecond: secStr }); totalSecond++; if (totalSecond < 0) { clearInterval(interval); //设置结束 that.setData({ totalSecond: totalSecond, countDownMinute: '00', countDownSecond: '00' }); } }.bind(this), 1000); }, // 停止录音 stop: function (e) { const that = this; recorderManager.stop(); clearInterval(interval); that.isrecordering = false; that.setData({ state: 'stop', countDownMinute: '00', countDownSecond: '00' }) that.setData({ JGH_recording1: true }) },
      2019-08-02
      回复
    查看更多(3)
登录 后发表内容