diff --git a/front/src/Components/EnableCamera/EnableCameraScene.svelte b/front/src/Components/EnableCamera/EnableCameraScene.svelte index dafd021b..5c06499c 100644 --- a/front/src/Components/EnableCamera/EnableCameraScene.svelte +++ b/front/src/Components/EnableCamera/EnableCameraScene.svelte @@ -2,9 +2,20 @@ import {Game} from "../../Phaser/Game/Game"; import {EnableCameraSceneName} from "../../Phaser/Login/EnableCameraScene"; import {localStreamStore} from "../../Stores/MediaStore"; + import { + audioConstraintStore, + cameraListStore, + localStreamStore, + microphoneListStore, + videoConstraintStore + } from "../../Stores/MediaStore"; import {onDestroy} from "svelte"; + import HorizontalSoundMeterWidget from "./HorizontalSoundMeterWidget.svelte"; + import cinemaCloseImg from "../images/cinema-close.svg"; export let game: Game; + let selectedCamera : string|null = null; + let selectedMicrophone : string|null = null; const enableCameraScene = game.scene.getScene(EnableCameraSceneName); @@ -23,28 +34,84 @@ } } - let stream : MediaStream|null; + let stream: MediaStream | null; const unsubscribe = localStreamStore.subscribe(value => { if (value.type === 'success') { stream = value.stream; + + if (stream !== null) { + const videoTracks = stream.getVideoTracks(); + if (videoTracks.length > 0) { + selectedCamera = videoTracks[0].getSettings().deviceId; + } + const audioTracks = stream.getAudioTracks(); + if (audioTracks.length > 0) { + selectedMicrophone = audioTracks[0].getSettings().deviceId; + } + } } else { stream = null; + selectedCamera = null; + selectedMicrophone = null; } }); onDestroy(unsubscribe); + function normalizeDeviceName(label: string): string { + // remove text in parenthesis + return label.replace(/\([^()]*\)/g, '').trim(); + } + + function selectCamera() { + videoConstraintStore.setDeviceId(selectedCamera); + } + + function selectMicrophone() { + audioConstraintStore.setDeviceId(selectedMicrophone); + } +
-
+

Turn on your camera and microphone

- - + +
+ + +
+ + {#if $cameraListStore.length > 1 } +
+ +
+ {/if} + + {#if $microphoneListStore.length > 1 } +
+ +
+ {/if} + +
+