优化
This commit is contained in:
@@ -129,6 +129,7 @@
|
|||||||
|
|
||||||
destroyed () {
|
destroyed () {
|
||||||
document.body.removeEventListener('touchmove', this.bindEvent)
|
document.body.removeEventListener('touchmove', this.bindEvent)
|
||||||
|
this.recorder.close()
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad () {
|
onLoad () {
|
||||||
@@ -149,6 +150,19 @@
|
|||||||
uni.$on('chooseEquipment', e => {
|
uni.$on('chooseEquipment', e => {
|
||||||
this.equipmentList = e.equipmentList
|
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: {
|
methods: {
|
||||||
@@ -158,6 +172,7 @@
|
|||||||
|
|
||||||
onLongtap () {
|
onLongtap () {
|
||||||
this.time = 60
|
this.time = 60
|
||||||
|
|
||||||
if (!this.equipmentList.length) {
|
if (!this.equipmentList.length) {
|
||||||
return this.$u.toast('请选择播发设备')
|
return this.$u.toast('请选择播发设备')
|
||||||
}
|
}
|
||||||
@@ -175,19 +190,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
record () {
|
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.recorder.start()
|
||||||
this.timing()
|
this.timing()
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
timing () {
|
timing () {
|
||||||
@@ -229,9 +233,6 @@
|
|||||||
stop (isCancel) {
|
stop (isCancel) {
|
||||||
clearTimeout(this.timingTimeout)
|
clearTimeout(this.timingTimeout)
|
||||||
this.recorder.stop((blob, duration) => {
|
this.recorder.stop((blob, duration) => {
|
||||||
this.recorder.close()
|
|
||||||
this.recorder = null
|
|
||||||
|
|
||||||
if (isCancel) {
|
if (isCancel) {
|
||||||
this.time = 60
|
this.time = 60
|
||||||
return false
|
return false
|
||||||
@@ -280,9 +281,7 @@
|
|||||||
console.log(blob, (window.URL || webkitURL).createObjectURL(blob), '时长:' + duration + 'ms')
|
console.log(blob, (window.URL || webkitURL).createObjectURL(blob), '时长:' + duration + 'ms')
|
||||||
}, msg => {
|
}, msg => {
|
||||||
console.log('录音失败:' + msg)
|
console.log('录音失败:' + msg)
|
||||||
this.recorder.close()
|
|
||||||
this.isShow = false
|
this.isShow = false
|
||||||
this.recorder = null
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user