record.js
458 Bytes
class RecorderManager {
constructor(options) {
const { duration, callback } = options || {};
this.recorderManager = uni.getRecorderManager();
this.start(duration);
this.recorderManager.onStop((res) => {
callback(res.tempFilePath);
});
}
start(duration = 60000) {
this.recorderManager.start({
duration,
sampleRate: 16000,
numberOfChannels: 1,
});
}
stop() {
this.recorderManager.stop();
}
}