This commit is contained in:
@@ -76,9 +76,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { toast } from 'vue3-toastify'
|
import { toast } from 'vue3-toastify'
|
||||||
import useModal from '@/composables/useModal'
|
import useModal from '@/composables/useModal'
|
||||||
import { computed, onBeforeUnmount, ref } from 'vue'
|
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||||
|
import { computed, nextTick, onBeforeUnmount, ref } from 'vue'
|
||||||
import { useUploadMediaMutation } from '@/services/query/auth'
|
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||||
import PermissionModal from '@/features/auth/components/studentRegister/PermissionModal.vue'
|
import PermissionModal from '@/features/auth/components/studentRegister/PermissionModal.vue'
|
||||||
|
|
||||||
@@ -170,9 +170,6 @@ const onStart = async () => {
|
|||||||
try {
|
try {
|
||||||
const constraints = props.kind === 'video' ? { audio: true, video: true } : { audio: true }
|
const constraints = props.kind === 'video' ? { audio: true, video: true } : { audio: true }
|
||||||
mediaStream = await navigator.mediaDevices.getUserMedia(constraints)
|
mediaStream = await navigator.mediaDevices.getUserMedia(constraints)
|
||||||
if (props.kind === 'video' && liveEl.value) {
|
|
||||||
liveEl.value.srcObject = mediaStream
|
|
||||||
}
|
|
||||||
chunks = []
|
chunks = []
|
||||||
recorderType = pickRecorderType(props.kind)
|
recorderType = pickRecorderType(props.kind)
|
||||||
mediaRecorder = new window.MediaRecorder(mediaStream, { mimeType: recorderType.mime })
|
mediaRecorder = new window.MediaRecorder(mediaStream, { mimeType: recorderType.mime })
|
||||||
@@ -180,8 +177,16 @@ const onStart = async () => {
|
|||||||
if (e.data?.size > 0) chunks.push(e.data)
|
if (e.data?.size > 0) chunks.push(e.data)
|
||||||
}
|
}
|
||||||
mediaRecorder.onstop = () => handleStop()
|
mediaRecorder.onstop = () => handleStop()
|
||||||
mediaRecorder.start()
|
|
||||||
isRecording.value = true
|
isRecording.value = true
|
||||||
|
|
||||||
|
// The live video is conditionally rendered by isRecording, so wait until
|
||||||
|
// Vue mounts it before attaching the camera stream.
|
||||||
|
await nextTick()
|
||||||
|
if (props.kind === 'video' && liveEl.value) {
|
||||||
|
liveEl.value.srcObject = mediaStream
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaRecorder.start()
|
||||||
elapsedMs.value = 0
|
elapsedMs.value = 0
|
||||||
timerStart = Date.now()
|
timerStart = Date.now()
|
||||||
timerHandle = setInterval(() => {
|
timerHandle = setInterval(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user