19 lines
487 B
Vue
19 lines
487 B
Vue
<script setup lang="ts">
|
|
const props = defineProps<{ stream: MediaStream | null; mirror?: boolean }>();
|
|
const video = ref<HTMLVideoElement>();
|
|
watch(
|
|
() => props.stream,
|
|
async (stream) => {
|
|
await nextTick();
|
|
if (video.value) {
|
|
video.value.srcObject = stream;
|
|
if (stream) void video.value.play().catch(() => {});
|
|
}
|
|
},
|
|
{ immediate: true },
|
|
);
|
|
</script>
|
|
<template>
|
|
<video ref="video" autoplay playsinline muted :class="{ mirrored: mirror }" />
|
|
</template>
|