2021-05-28 15:48:58 +02:00
|
|
|
<script lang="typescript">
|
2021-12-06 16:12:37 +01:00
|
|
|
import { obtainedMediaConstraintStore } from "../Stores/MediaStore";
|
|
|
|
import { localStreamStore, isSilentStore } from "../Stores/MediaStore";
|
2021-05-28 15:48:58 +02:00
|
|
|
import SoundMeterWidget from "./SoundMeterWidget.svelte";
|
2022-01-05 10:27:40 +01:00
|
|
|
import { onDestroy, onMount } from "svelte";
|
2021-12-06 16:12:37 +01:00
|
|
|
import { srcObject } from "./Video/utils";
|
2022-01-21 17:06:03 +01:00
|
|
|
import LL from "../i18n/i18n-svelte";
|
2021-05-28 15:48:58 +02:00
|
|
|
|
2021-12-06 16:12:37 +01:00
|
|
|
let stream: MediaStream | null;
|
2021-05-28 15:48:58 +02:00
|
|
|
|
2021-12-06 16:12:37 +01:00
|
|
|
const unsubscribe = localStreamStore.subscribe((value) => {
|
|
|
|
if (value.type === "success") {
|
2021-05-28 15:48:58 +02:00
|
|
|
stream = value.stream;
|
|
|
|
} else {
|
|
|
|
stream = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
onDestroy(unsubscribe);
|
|
|
|
|
2021-09-05 18:36:22 +02:00
|
|
|
let isSilent: boolean;
|
2021-12-06 16:12:37 +01:00
|
|
|
const unsubscribeIsSilent = isSilentStore.subscribe((value) => {
|
2021-09-05 18:36:22 +02:00
|
|
|
isSilent = value;
|
|
|
|
});
|
|
|
|
|
2022-01-05 10:27:40 +01:00
|
|
|
let cameraContainer: HTMLDivElement;
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
cameraContainer.addEventListener("transitionend", () => {
|
|
|
|
if (cameraContainer.classList.contains("hide")) {
|
|
|
|
cameraContainer.style.visibility = "hidden";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
cameraContainer.addEventListener("transitionstart", () => {
|
|
|
|
if (!cameraContainer.classList.contains("hide")) {
|
|
|
|
cameraContainer.style.visibility = "visible";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-05 18:36:22 +02:00
|
|
|
onDestroy(unsubscribeIsSilent);
|
2021-05-28 15:48:58 +02:00
|
|
|
</script>
|
|
|
|
|
2022-01-05 10:27:40 +01:00
|
|
|
<div
|
|
|
|
class="nes-container is-rounded my-cam-video-container"
|
|
|
|
class:hide={($localStreamStore.type !== "success" || !$obtainedMediaConstraintStore.video) && !isSilent}
|
|
|
|
bind:this={cameraContainer}
|
|
|
|
>
|
|
|
|
{#if isSilent}
|
|
|
|
<div class="is-silent">{$LL.camera.my.silentZone()}</div>
|
|
|
|
{:else if $localStreamStore.type === "success" && $localStreamStore.stream}
|
|
|
|
<video class="my-cam-video" use:srcObject={stream} autoplay muted playsinline />
|
|
|
|
<SoundMeterWidget {stream} />
|
|
|
|
{/if}
|
2021-05-28 15:48:58 +02:00
|
|
|
</div>
|
2022-01-05 10:27:40 +01:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import "../../style/breakpoints.scss";
|
|
|
|
|
|
|
|
.my-cam-video-container {
|
|
|
|
position: absolute;
|
|
|
|
right: 15px;
|
|
|
|
bottom: 30px;
|
|
|
|
max-height: 20%;
|
|
|
|
transition: transform 1000ms;
|
|
|
|
padding: 0;
|
|
|
|
background-color: #00000099;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.my-cam-video-container.hide {
|
|
|
|
transform: translateX(200%);
|
|
|
|
}
|
|
|
|
|
|
|
|
.my-cam-video {
|
|
|
|
background-color: #00000099;
|
|
|
|
max-height: 20vh;
|
|
|
|
width: 100%;
|
|
|
|
-webkit-transform: scaleX(-1);
|
|
|
|
transform: scaleX(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
.is-silent {
|
|
|
|
font-size: 2em;
|
|
|
|
color: white;
|
|
|
|
padding: 40px 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@include media-breakpoint-up(md) {
|
|
|
|
.my-cam-video {
|
|
|
|
width: 150px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.my-cam-video-container.hide {
|
|
|
|
right: -160px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|