开发
API

RecorderManager.resume

继续录音。在调用暂停录音之后,可以调用 resume 继续录音,继续录音的内容会拼接到上一次暂停录音之后。

语法

RecorderManager.resume()

参数说明

代码示例

<!-- index.ttml -->
<button type="primary" bindtap="startRecord">开始录音</button>
<button type="primary" bindtap="pauseRecord">暂停录音</button>
<button type="primary" bindtap="resumeRecord">resumeRecord</button>
<view>录音状态:{{status}}</view>
// index.js

Page({
  data: {
    status: "暂未开始",
  },
  startRecord() {
    this.recorderManager = tt.getRecorderManager();
    const options = {
      duration: 60000,
      sampleRate: 12000,
      numberOfChannels: 1,
      encodeBitRate: 25000,
      frameSize: 100,
    };
    this.recorderManager.start(options);
    tt.showToast({ title: "点击了开始录音" });
    this.setData({
      status: "正在录音",
    });
  },
  pauseRecord() {
    if (this.recorderManager) {
      this.recorderManager.pause();
      tt.showToast({ title: "点击了暂停录音" });
      this.setData({
        status: "暂停录音",
      });
    }
  },
  resumeRecord() {
    if (this.recorderManager) {
      this.recorderManager.resume();
      tt.showToast({ title: "点击了继续录音" });
      this.setData({
        status: "正在录音",
      });
    }
  },
});

Bug & Tip

暂无

点击纠错
评价此篇文档