1.安装
npm i js-audio-recorder
2.使用
准备
import Recorder from 'js-audio-recorder'
data() {
return {
recorder: null,
playTime: 0,
timer: null,
src: null
}
},
created() {
this.recorder = new Recorder()
},
开始录音
this.recorder = new Recorder()
Recorder.getPermission().then(() => {
this.recorder.start() // 开始录音
}, (error) => {
})
停止录音
this.recorder.stop() // 停止录音
继续录音
this.recorder.resume() // 恢复录音
暂停录音
this.recorder.pause() // 暂停录音
销毁录音
this.recorder.destroy() // 毁实例
播放录音
this.recorder.play() // 播放录音
注:插件在http中不能使用,需要在https中,