workadventure/front/src/Components/Video/ScreenSharingMediaBox.svelte

59 lines
1.6 KiB
Svelte
Raw Normal View History

<script lang="ts">
2022-01-05 10:27:40 +01:00
import { highlightedEmbedScreen } from "../../Stores/EmbedScreensStore";
import type { EmbedScreen } from "../../Stores/EmbedScreensStore";
import type { Streamable } from "../../Stores/StreamableCollectionStore";
2021-12-06 16:12:37 +01:00
import type { ScreenSharingPeer } from "../../WebRtc/ScreenSharingPeer";
import { getColorByString, srcObject } from "./utils";
2022-01-05 10:27:40 +01:00
export let clickable = false;
export let peer: ScreenSharingPeer;
let streamStore = peer.streamStore;
let name = peer.userName;
let statusStore = peer.statusStore;
2022-01-05 10:27:40 +01:00
let embedScreen: EmbedScreen;
if (peer) {
embedScreen = {
type: "streamable",
embed: peer as unknown as Streamable,
};
}
</script>
<div class="video-container">
2021-12-06 16:12:37 +01:00
{#if $statusStore === "connecting"}
<div class="connecting-spinner" />
{/if}
2021-12-06 16:12:37 +01:00
{#if $statusStore === "error"}
<div class="rtc-error" />
{/if}
{#if $streamStore !== null}
2021-12-06 16:12:37 +01:00
<!-- svelte-ignore a11y-media-has-caption -->
<i class="container">
<span style="background-color: {getColorByString(name)};">{name}</span>
</i>
2022-01-05 10:27:40 +01:00
<video
use:srcObject={$streamStore}
autoplay
playsinline
on:click={() => (clickable ? highlightedEmbedScreen.toggleHighlight(embedScreen) : null)}
/>
{/if}
</div>
<style lang="scss">
2021-12-06 16:12:37 +01:00
.video-container {
video {
width: 100%;
}
i {
span {
padding: 2px 32px;
}
}
}
</style>