This commit is contained in:
yanran200730
2022-06-21 17:03:05 +08:00
parent 937bcadde7
commit e3e0600bf0

View File

@@ -129,6 +129,7 @@
destroyed () {
document.body.removeEventListener('touchmove', this.bindEvent)
this.recorder.close()
},
onLoad () {
@@ -149,6 +150,19 @@
uni.$on('chooseEquipment', e => {
this.equipmentList = e.equipmentList
})
this.recorder = Recorder({
type: 'mp3',
sampleRate: 16000,
bitRate: 16,
onProcess(buffers, powerLevel, bufferDuration, bufferSampleRate, newBufferIdx, asyncEnd) {
//可利用extensions/waveview.js扩展实时绘制波形
}
})
this.recorder.open((e) => {
console.log(e)
}, e => {
console.log(e)
})
},
methods: {
@@ -158,6 +172,7 @@
onLongtap () {
this.time = 60
if (!this.equipmentList.length) {
return this.$u.toast('请选择播发设备')
}
@@ -175,19 +190,8 @@
},
record () {
this.recorder = Recorder({
type: 'mp3',
sampleRate: 16000,
bitRate: 16,
onProcess(buffers, powerLevel, bufferDuration, bufferSampleRate, newBufferIdx, asyncEnd) {
//可利用extensions/waveview.js扩展实时绘制波形
}
})
this.recorder.open(() => {
this.recorder.start()
this.timing()
})
this.recorder.start()
this.timing()
},
timing () {
@@ -229,9 +233,6 @@
stop (isCancel) {
clearTimeout(this.timingTimeout)
this.recorder.stop((blob, duration) => {
this.recorder.close()
this.recorder = null
if (isCancel) {
this.time = 60
return false
@@ -280,9 +281,7 @@
console.log(blob, (window.URL || webkitURL).createObjectURL(blob), '时长:' + duration + 'ms')
}, msg => {
console.log('录音失败:' + msg)
this.recorder.close()
this.isShow = false
this.recorder = null
})
},