2022-01-31 17:30:07 +01:00
|
|
|
<script lang="ts">
|
2022-02-03 14:51:47 +01:00
|
|
|
import { localVolumeStore, obtainedMediaConstraintStore } from "../Stores/MediaStore";
|
2021-12-06 16:12:37 +01:00
|
|
|
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
|
|
|
|
2022-02-03 14:51:47 +01:00
|
|
|
const unsubscribeLocalStreamStore = localStreamStore.subscribe((value) => {
|
2021-12-06 16:12:37 +01:00
|
|
|
if (value.type === "success") {
|
2021-05-28 15:48:58 +02:00
|
|
|
stream = value.stream;
|
|
|
|
} else {
|
|
|
|
stream = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-02-03 14:51:47 +01:00
|
|
|
onDestroy(() => {
|
|
|
|
unsubscribeLocalStreamStore();
|
|
|
|
});
|
2021-05-28 15:48:58 +02:00
|
|
|
|
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 />
|
2022-02-08 11:54:18 +01:00
|
|
|
<SoundMeterWidget volume={$localVolumeStore} />
|
2022-01-05 10:27:40 +01:00
|
|
|
{/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;
|
2022-01-17 10:04:54 +01:00
|
|
|
background-color: rgba(#000000, 0.6);
|
|
|
|
background-clip: content-box;
|
2022-01-05 10:27:40 +01:00
|
|
|
overflow: hidden;
|
2022-01-11 13:52:38 +01:00
|
|
|
line-height: 0;
|
2022-01-17 10:04:54 +01:00
|
|
|
z-index: 250;
|
2022-01-11 13:52:38 +01:00
|
|
|
|
|
|
|
&.nes-container.is-rounded {
|
|
|
|
border-image-outset: 1;
|
|
|
|
}
|
2022-01-05 10:27:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.my-cam-video-container.hide {
|
|
|
|
transform: translateX(200%);
|
|
|
|
}
|
|
|
|
|
|
|
|
.my-cam-video {
|
|
|
|
background-color: #00000099;
|
|
|
|
max-height: 20vh;
|
2022-01-11 13:52:38 +01:00
|
|
|
max-width: max(25vw, 150px);
|
2022-01-05 10:27:40 +01:00
|
|
|
width: 100%;
|
|
|
|
-webkit-transform: scaleX(-1);
|
|
|
|
transform: scaleX(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
.is-silent {
|
|
|
|
font-size: 2em;
|
|
|
|
color: white;
|
|
|
|
padding: 40px 20px;
|
|
|
|
}
|
|
|
|
</style>
|