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

25 lines
803 B
Svelte
Raw Normal View History

<script lang="typescript">
2021-06-14 17:59:50 +02:00
import {ScreenSharingLocalMedia} from "../../Stores/ScreenSharingStore";
import {videoFocusStore} from "../../Stores/VideoFocusStore";
2021-06-14 17:59:50 +02:00
function srcObject(node, stream) {
node.srcObject = stream;
return {
update(newStream) {
if (node.srcObject != newStream) {
node.srcObject = newStream
}
}
}
}
2021-06-14 17:59:50 +02:00
export let peer : ScreenSharingLocalMedia;
let stream : MediaStream|undefined = peer.stream;
export let cssClass : string|undefined;
</script>
<div class="video-container {cssClass ? cssClass : ''}" class:hide={!stream}>
<video use:srcObject={stream} autoplay muted playsinline on:click={() => videoFocusStore.toggleFocus(peer)}></video>
</div>