Hotfix media constraint error
- Create error to manage displayed warning when we try to access on media with no constraint video and audio - Fix disabled microphone if we try to active and we don't have right or there is an error. Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
parent
4f0bb95a38
commit
f2ca021740
3 changed files with 35 additions and 14 deletions
10
front/src/Stores/Errors/MediaStreamConstraintsError.ts
Normal file
10
front/src/Stores/Errors/MediaStreamConstraintsError.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
export class MediaStreamConstraintsError extends Error {
|
||||||
|
static NAME = "MediaStreamConstraintsError";
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(
|
||||||
|
"Unable to access your camera or microphone. Your browser is too old. Please consider upgrading your browser or try using a recent version of Chrome."
|
||||||
|
);
|
||||||
|
this.name = MediaStreamConstraintsError.NAME;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import { WebviewOnOldIOS } from "./Errors/WebviewOnOldIOS";
|
||||||
import { gameOverlayVisibilityStore } from "./GameOverlayStoreVisibility";
|
import { gameOverlayVisibilityStore } from "./GameOverlayStoreVisibility";
|
||||||
import { peerStore } from "./PeerStore";
|
import { peerStore } from "./PeerStore";
|
||||||
import { privacyShutdownStore } from "./PrivacyShutdownStore";
|
import { privacyShutdownStore } from "./PrivacyShutdownStore";
|
||||||
|
import { MediaStreamConstraintsError } from "./Errors/MediaStreamConstraintsError";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A store that contains the camera state requested by the user (on or off).
|
* A store that contains the camera state requested by the user (on or off).
|
||||||
|
@ -251,8 +252,6 @@ export const mediaStreamConstraintsStore = derived(
|
||||||
let currentAudioConstraint: boolean | MediaTrackConstraints = $audioConstraintStore;
|
let currentAudioConstraint: boolean | MediaTrackConstraints = $audioConstraintStore;
|
||||||
|
|
||||||
if ($enableCameraSceneVisibilityStore) {
|
if ($enableCameraSceneVisibilityStore) {
|
||||||
console.log("currentVideoConstraint", currentVideoConstraint);
|
|
||||||
console.log("currentAudioConstraint", currentAudioConstraint);
|
|
||||||
set({
|
set({
|
||||||
video: currentVideoConstraint,
|
video: currentVideoConstraint,
|
||||||
audio: currentAudioConstraint,
|
audio: currentAudioConstraint,
|
||||||
|
@ -421,7 +420,7 @@ export const localStreamStore = derived<Readable<MediaStreamConstraints>, LocalS
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (constraints.video !== false) {
|
if (constraints.video !== false || constraints.audio !== false) {
|
||||||
console.info(
|
console.info(
|
||||||
"Error. Unable to get microphone and/or camera access. Trying audio only.",
|
"Error. Unable to get microphone and/or camera access. Trying audio only.",
|
||||||
$mediaStreamConstraintsStore,
|
$mediaStreamConstraintsStore,
|
||||||
|
@ -433,7 +432,17 @@ export const localStreamStore = derived<Readable<MediaStreamConstraints>, LocalS
|
||||||
error: e,
|
error: e,
|
||||||
});
|
});
|
||||||
// Let's try without video constraints
|
// Let's try without video constraints
|
||||||
|
if (constraints.video !== false) {
|
||||||
requestedCameraState.disableWebcam();
|
requestedCameraState.disableWebcam();
|
||||||
|
}
|
||||||
|
if (constraints.audio !== false) {
|
||||||
|
requestedMicrophoneState.disableMicrophone();
|
||||||
|
}
|
||||||
|
} else if (!constraints.video && !constraints.audio) {
|
||||||
|
set({
|
||||||
|
type: "error",
|
||||||
|
error: new MediaStreamConstraintsError(),
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.info(
|
console.info(
|
||||||
"Error. Unable to get microphone and/or camera access.",
|
"Error. Unable to get microphone and/or camera access.",
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { gameOverlayVisibilityStore } from "../Stores/GameOverlayStoreVisibility
|
||||||
import { layoutManagerActionStore, layoutManagerVisibilityStore } from "../Stores/LayoutManagerStore";
|
import { layoutManagerActionStore, layoutManagerVisibilityStore } from "../Stores/LayoutManagerStore";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { localUserStore } from "../Connexion/LocalUserStore";
|
import { localUserStore } from "../Connexion/LocalUserStore";
|
||||||
|
import { MediaStreamConstraintsError } from "../Stores/Errors/MediaStreamConstraintsError";
|
||||||
|
|
||||||
export class MediaManager {
|
export class MediaManager {
|
||||||
startScreenSharingCallBacks: Set<StartScreenSharingCallback> = new Set<StartScreenSharingCallback>();
|
startScreenSharingCallBacks: Set<StartScreenSharingCallback> = new Set<StartScreenSharingCallback>();
|
||||||
|
@ -24,7 +25,7 @@ export class MediaManager {
|
||||||
constructor() {
|
constructor() {
|
||||||
localStreamStore.subscribe((result) => {
|
localStreamStore.subscribe((result) => {
|
||||||
if (result.type === "error") {
|
if (result.type === "error") {
|
||||||
console.error(result.error);
|
if (result.error.name !== MediaStreamConstraintsError.NAME) {
|
||||||
layoutManagerActionStore.addAction({
|
layoutManagerActionStore.addAction({
|
||||||
uuid: "cameraAccessDenied",
|
uuid: "cameraAccessDenied",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
|
@ -34,6 +35,7 @@ export class MediaManager {
|
||||||
},
|
},
|
||||||
userInputManager: this.userInputManager,
|
userInputManager: this.userInputManager,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
//remove it after 10 sec
|
//remove it after 10 sec
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
layoutManagerActionStore.removeAction("cameraAccessDenied");
|
layoutManagerActionStore.removeAction("cameraAccessDenied");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue