2021-06-11 11:29:36 +02:00
|
|
|
<script lang="ts">
|
2021-11-26 23:30:21 +01:00
|
|
|
import type { VideoPeer } from "../../WebRtc/VideoPeer";
|
2021-06-11 11:29:36 +02:00
|
|
|
import SoundMeterWidget from "../SoundMeterWidget.svelte";
|
|
|
|
import microphoneCloseImg from "../images/microphone-close.svg";
|
|
|
|
import reportImg from "./images/report.svg";
|
|
|
|
import blockSignImg from "./images/blockSign.svg";
|
2021-11-26 23:30:21 +01:00
|
|
|
import { videoFocusStore } from "../../Stores/VideoFocusStore";
|
|
|
|
import { showReportScreenStore } from "../../Stores/ShowReportScreenStore";
|
|
|
|
import { userWokaPictureStore } from "../../Stores/UserWokaPictureStore";
|
|
|
|
import { getColorByString, srcObject } from "./utils";
|
|
|
|
import { onDestroy } from "svelte";
|
2021-06-11 11:29:36 +02:00
|
|
|
|
|
|
|
export let peer: VideoPeer;
|
|
|
|
let streamStore = peer.streamStore;
|
|
|
|
let name = peer.userName;
|
|
|
|
let statusStore = peer.statusStore;
|
|
|
|
let constraintStore = peer.constraintsStore;
|
|
|
|
|
2021-11-26 23:30:21 +01:00
|
|
|
let userWokaPictureSrc: string | undefined = undefined;
|
|
|
|
|
|
|
|
const unsubscribeFromUserWokaPictureStore = userWokaPictureStore.subscribe((playersAvatars) => {
|
|
|
|
userWokaPictureSrc = playersAvatars.get(peer.userId);
|
|
|
|
console.log(userWokaPictureSrc);
|
|
|
|
});
|
|
|
|
|
2021-06-15 15:16:01 +02:00
|
|
|
function openReport(peer: VideoPeer): void {
|
2021-11-26 23:30:21 +01:00
|
|
|
showReportScreenStore.set({ userId: peer.userId, userName: peer.userName });
|
2021-06-15 15:16:01 +02:00
|
|
|
}
|
|
|
|
|
2021-11-26 23:30:21 +01:00
|
|
|
onDestroy(unsubscribeFromUserWokaPictureStore);
|
2021-06-11 11:29:36 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="video-container">
|
2021-11-26 23:30:21 +01:00
|
|
|
{#if $statusStore === "connecting"}
|
|
|
|
<div class="connecting-spinner" />
|
2021-06-11 11:29:36 +02:00
|
|
|
{/if}
|
2021-11-26 23:30:21 +01:00
|
|
|
{#if $statusStore === "error"}
|
|
|
|
<div class="rtc-error" />
|
2021-06-11 11:29:36 +02:00
|
|
|
{/if}
|
|
|
|
{#if !$constraintStore || $constraintStore.video === false}
|
2021-11-26 23:30:21 +01:00
|
|
|
<i style="background-color: {getColorByString(name)};">
|
|
|
|
{#if !userWokaPictureSrc}
|
|
|
|
{name}
|
|
|
|
{:else}
|
|
|
|
<img src={userWokaPictureSrc} class="user-woka-picture" alt="player avatar" />
|
|
|
|
{/if}
|
|
|
|
</i>
|
2021-06-11 11:29:36 +02:00
|
|
|
{/if}
|
|
|
|
{#if $constraintStore && $constraintStore.audio === false}
|
2021-11-26 23:30:21 +01:00
|
|
|
<img src={microphoneCloseImg} class="active" alt="Muted" />
|
2021-06-11 11:29:36 +02:00
|
|
|
{/if}
|
2021-06-15 15:16:01 +02:00
|
|
|
<button class="report" on:click={() => openReport(peer)}>
|
2021-11-26 23:30:21 +01:00
|
|
|
<img alt="Report this user" src={reportImg} />
|
2021-06-11 11:29:36 +02:00
|
|
|
<span>Report/Block</span>
|
|
|
|
</button>
|
2021-11-26 23:30:21 +01:00
|
|
|
<video use:srcObject={$streamStore} autoplay playsinline on:click={() => videoFocusStore.toggleFocus(peer)} />
|
2021-06-15 15:16:01 +02:00
|
|
|
<img src={blockSignImg} class="block-logo" alt="Block" />
|
2021-06-11 11:29:36 +02:00
|
|
|
{#if $constraintStore && $constraintStore.audio !== false}
|
2021-11-26 23:30:21 +01:00
|
|
|
<SoundMeterWidget stream={$streamStore} />
|
2021-06-11 11:29:36 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
2021-11-26 23:30:21 +01:00
|
|
|
<style lang="scss">
|
|
|
|
.user-woka-picture {
|
|
|
|
display: block;
|
|
|
|
left: calc(50% - 45px);
|
|
|
|
top: calc(50% - 45px);
|
|
|
|
width: 90px;
|
|
|
|
height: 90px;
|
2021-11-26 23:49:49 +01:00
|
|
|
image-rendering: pixelated;
|
2021-11-26 23:30:21 +01:00
|
|
|
}
|
|
|
|
</style>
|