partey_workadventure/front/src/Components/MyCamera.svelte

31 lines
951 B
Svelte
Raw Normal View History

2021-05-28 15:48:58 +02:00
<script lang="typescript">
import {obtainedMediaConstraintStore} from "../Stores/MediaStore";
2021-05-28 15:48:58 +02:00
import {localStreamStore} from "../Stores/MediaStore";
import SoundMeterWidget from "./SoundMeterWidget.svelte";
import {onDestroy} from "svelte";
import {srcObject} from "./Video/utils";
2021-05-28 15:48:58 +02:00
let stream : MediaStream|null;
const unsubscribe = localStreamStore.subscribe(value => {
if (value.type === 'success') {
stream = value.stream;
} else {
stream = null;
}
});
onDestroy(unsubscribe);
</script>
<div>
<div class="video-container div-myCamVideo" class:hide={!$obtainedMediaConstraintStore.video}>
{#if $localStreamStore.type === "success" && $localStreamStore.stream}
<video class="myCamVideo" use:srcObject={stream} autoplay muted playsinline></video>
2021-05-28 15:48:58 +02:00
<SoundMeterWidget stream={stream}></SoundMeterWidget>
2021-06-15 18:34:11 +02:00
{/if}
2021-05-28 15:48:58 +02:00
</div>
</div>