2021-05-28 09:31:04 +02:00
|
|
|
<script lang="typescript">
|
2021-12-06 16:12:37 +01:00
|
|
|
import { requestedScreenSharingState, screenSharingAvailableStore } from "../Stores/ScreenSharingStore";
|
|
|
|
import { isSilentStore, requestedCameraState, requestedMicrophoneState } from "../Stores/MediaStore";
|
2021-05-28 09:31:04 +02:00
|
|
|
import monitorImg from "./images/monitor.svg";
|
|
|
|
import monitorCloseImg from "./images/monitor-close.svg";
|
|
|
|
import cinemaImg from "./images/cinema.svg";
|
|
|
|
import cinemaCloseImg from "./images/cinema-close.svg";
|
|
|
|
import microphoneImg from "./images/microphone.svg";
|
|
|
|
import microphoneCloseImg from "./images/microphone-close.svg";
|
2021-06-17 18:30:08 +02:00
|
|
|
import layoutPresentationImg from "./images/layout-presentation.svg";
|
|
|
|
import layoutChatImg from "./images/layout-chat.svg";
|
2021-12-06 16:12:37 +01:00
|
|
|
import { layoutModeStore } from "../Stores/StreamableCollectionStore";
|
|
|
|
import { LayoutMode } from "../WebRtc/LayoutManager";
|
|
|
|
import { peerStore } from "../Stores/PeerStore";
|
|
|
|
import { onDestroy } from "svelte";
|
2021-05-28 09:31:04 +02:00
|
|
|
|
|
|
|
function screenSharingClick(): void {
|
2021-10-06 17:59:20 +02:00
|
|
|
if (isSilent) return;
|
2021-05-28 09:31:04 +02:00
|
|
|
if ($requestedScreenSharingState === true) {
|
|
|
|
requestedScreenSharingState.disableScreenSharing();
|
|
|
|
} else {
|
|
|
|
requestedScreenSharingState.enableScreenSharing();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function cameraClick(): void {
|
2021-10-06 17:59:20 +02:00
|
|
|
if (isSilent) return;
|
2021-05-28 09:31:04 +02:00
|
|
|
if ($requestedCameraState === true) {
|
|
|
|
requestedCameraState.disableWebcam();
|
|
|
|
} else {
|
|
|
|
requestedCameraState.enableWebcam();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function microphoneClick(): void {
|
2021-10-06 17:59:20 +02:00
|
|
|
if (isSilent) return;
|
2021-05-28 09:31:04 +02:00
|
|
|
if ($requestedMicrophoneState === true) {
|
|
|
|
requestedMicrophoneState.disableMicrophone();
|
|
|
|
} else {
|
|
|
|
requestedMicrophoneState.enableMicrophone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-15 17:30:28 +02:00
|
|
|
function switchLayoutMode() {
|
|
|
|
if ($layoutModeStore === LayoutMode.Presentation) {
|
|
|
|
$layoutModeStore = LayoutMode.VideoChat;
|
|
|
|
} else {
|
|
|
|
$layoutModeStore = LayoutMode.Presentation;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
});
|
|
|
|
onDestroy(unsubscribeIsSilent);
|
2021-05-28 09:31:04 +02:00
|
|
|
</script>
|
|
|
|
|
2021-06-02 09:58:00 +02:00
|
|
|
<div>
|
|
|
|
<div class="btn-cam-action">
|
2021-06-15 17:30:28 +02:00
|
|
|
<div class="btn-layout" on:click={switchLayoutMode} class:hide={$peerStore.size === 0}>
|
2021-12-06 16:12:37 +01:00
|
|
|
{#if $layoutModeStore === LayoutMode.Presentation}
|
|
|
|
<img src={layoutPresentationImg} style="padding: 2px" alt="Switch to mosaic mode" />
|
2021-06-15 17:30:28 +02:00
|
|
|
{:else}
|
2021-12-06 16:12:37 +01:00
|
|
|
<img src={layoutChatImg} style="padding: 2px" alt="Switch to presentation mode" />
|
2021-06-15 17:30:28 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
2021-12-06 16:12:37 +01:00
|
|
|
<div
|
|
|
|
class="btn-monitor"
|
|
|
|
on:click={screenSharingClick}
|
|
|
|
class:hide={!$screenSharingAvailableStore || isSilent}
|
|
|
|
class:enabled={$requestedScreenSharingState}
|
|
|
|
>
|
2021-09-05 18:36:22 +02:00
|
|
|
{#if $requestedScreenSharingState && !isSilent}
|
2021-12-06 16:12:37 +01:00
|
|
|
<img src={monitorImg} alt="Start screen sharing" />
|
2021-06-02 09:58:00 +02:00
|
|
|
{:else}
|
2021-12-06 16:12:37 +01:00
|
|
|
<img src={monitorCloseImg} alt="Stop screen sharing" />
|
2021-06-02 09:58:00 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
2021-09-05 18:36:22 +02:00
|
|
|
<div class="btn-video" on:click={cameraClick} class:disabled={!$requestedCameraState || isSilent}>
|
|
|
|
{#if $requestedCameraState && !isSilent}
|
2021-12-06 16:12:37 +01:00
|
|
|
<img src={cinemaImg} alt="Turn on webcam" />
|
2021-06-02 09:58:00 +02:00
|
|
|
{:else}
|
2021-12-06 16:12:37 +01:00
|
|
|
<img src={cinemaCloseImg} alt="Turn off webcam" />
|
2021-06-02 09:58:00 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
2021-09-05 18:36:22 +02:00
|
|
|
<div class="btn-micro" on:click={microphoneClick} class:disabled={!$requestedMicrophoneState || isSilent}>
|
|
|
|
{#if $requestedMicrophoneState && !isSilent}
|
2021-12-06 16:12:37 +01:00
|
|
|
<img src={microphoneImg} alt="Turn on microphone" />
|
2021-06-02 09:58:00 +02:00
|
|
|
{:else}
|
2021-12-06 16:12:37 +01:00
|
|
|
<img src={microphoneCloseImg} alt="Turn off microphone" />
|
2021-06-02 09:58:00 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
2021-05-28 09:31:04 +02:00
|
|
|
</div>
|
|
|
|
</div>
|