diff --git a/src/apps/AppBroadcast/LiveBroadcast.vue b/src/apps/AppBroadcast/LiveBroadcast.vue index 38c42dca..fbd81e01 100644 --- a/src/apps/AppBroadcast/LiveBroadcast.vue +++ b/src/apps/AppBroadcast/LiveBroadcast.vue @@ -63,7 +63,7 @@ -

{{ time }}

+

{{ time }}S

@@ -93,8 +93,7 @@ isRecording: false, recorder: null, blobFile: null, - counterDownTime: 0, - time: '00:00:00', + time: 60, timingTimeout: null, equipmentList: [], recordList: [], @@ -192,13 +191,11 @@ }, timing () { - var durationObj = this.$dayjs.duration(this.counterDownTime * 1000) - var hours = durationObj.hours() > 9 ? durationObj.hours() : '0' + durationObj.hours() - var min = durationObj.minutes() > 9 ? durationObj.minutes() : '0' + durationObj.minutes() - var seconds = durationObj.seconds() > 9 ? durationObj.seconds() : '0' + durationObj.seconds() + this.time = this.time - 1 - this.time = hours + ':' + min + ':' + seconds - this.counterDownTime++ + if (this.time === 0) { + this.stop() + } this.timingTimeout = setTimeout(() => { this.timing() }, 1000) @@ -238,17 +235,16 @@ }, stop (isCancel) { - this.counterDownTime = 0 clearTimeout(this.timingTimeout) this.recorder.stop((blob, duration) => { this.recorder.close() this.recorder = null if (isCancel) { + this.time = 60 return false } - this.time = '00:00:00' let formData = {} formData = new FormData() formData.append('file', new window.File([blob], `${(new Date).getTime()}` )) @@ -286,6 +282,8 @@ }).catch(() => { this.isShow = false }) + + this.time = 60 console.log(blob, (window.URL || webkitURL).createObjectURL(blob), '时长:' + duration + 'ms') }, msg => { console.log('录音失败:' + msg)