partey_workadventure/front/src/Components/MyCamera.svelte

42 lines
1.2 KiB
Svelte
Raw Normal View History

2021-05-28 15:48:58 +02:00
<script lang="typescript">
import {obtainedMediaConstraintStore} from "../Stores/MediaStore";
import {localStreamStore, isSilentStore} from "../Stores/MediaStore";
2021-05-28 15:48:58 +02:00
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);
let isSilent: boolean;
const unsubscribeIsSilent = isSilentStore.subscribe(value => {
isSilent = value;
});
onDestroy(unsubscribeIsSilent);
2021-05-28 15:48:58 +02:00
</script>
<div>
<div class="video-container div-myCamVideo" class:hide={!$obtainedMediaConstraintStore.video || isSilent}>
{#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 class="is-silent" class:hide={isSilent}>
Silent zone
</div>
2021-05-28 15:48:58 +02:00
</div>