|
|
@@ -15,6 +15,7 @@ import {
|
|
|
} from 'vue'
|
|
|
import useStore from '@/store'
|
|
|
|
|
|
+const props = withDefaults(defineProps<{ time?: number }>(), { time: 5000 })
|
|
|
const emit = defineEmits<{(evt: 'callBack', value: Blob): void }>()
|
|
|
const store = useStore()
|
|
|
const notice = useNotification()
|
|
|
@@ -22,6 +23,7 @@ const show = ref(false)
|
|
|
const rtcConnected = computed(() => store.rtcConnected)
|
|
|
let chunks = [] as Blob[]
|
|
|
let audio = null as null | MediaRecorder
|
|
|
+let timer = null as Any
|
|
|
|
|
|
async function initMic() {
|
|
|
try {
|
|
|
@@ -54,7 +56,7 @@ function change() {
|
|
|
if (!rtcConnected.value) return
|
|
|
show.value = !show.value
|
|
|
if (!audio) return
|
|
|
- if (show.value) { audio.start() } else { audio.stop() }
|
|
|
+ if (show.value) { audio?.start(); timer = setTimeout(() => { show.value = false; audio?.stop() }, props.time) } else { audio?.stop(); clearTimeout(timer) }
|
|
|
console.log('mic', show.value)
|
|
|
}
|
|
|
|