From a3e244285c2ea237df265ffcf60682c2149ca9cb Mon Sep 17 00:00:00 2001 From: zisra <100528712+zisra@users.noreply.github.com> Date: Sat, 4 Mar 2023 10:24:56 -0600 Subject: [PATCH] mrvjs suggested changes --- .../components/actions/PictureInPictureAction.tsx | 1 - src/video/state/init.ts | 1 - src/video/state/providers/castingStateProvider.ts | 2 +- src/video/state/providers/videoStateProvider.ts | 10 +--------- src/video/state/types.ts | 1 - 5 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/video/components/actions/PictureInPictureAction.tsx b/src/video/components/actions/PictureInPictureAction.tsx index f2529b8a..d60ec446 100644 --- a/src/video/components/actions/PictureInPictureAction.tsx +++ b/src/video/components/actions/PictureInPictureAction.tsx @@ -32,7 +32,6 @@ export function PictureInPictureAction(props: Props) { className={props.className} icon={Icons.PICTURE_IN_PICTURE} onClick={handleClick} - disabled={false} text={ isMobile ? (t("videoPlayer.buttons.pictureInPicture") as string) : "" } diff --git a/src/video/state/init.ts b/src/video/state/init.ts index 6a67777d..13118a1d 100644 --- a/src/video/state/init.ts +++ b/src/video/state/init.ts @@ -31,7 +31,6 @@ function initPlayer(): VideoPlayerState { isFocused: false, leftControlHovering: false, popoutBounds: null, - isPictureInPicture: false, }, mediaPlaying: { diff --git a/src/video/state/providers/castingStateProvider.ts b/src/video/state/providers/castingStateProvider.ts index fb563974..6efa499e 100644 --- a/src/video/state/providers/castingStateProvider.ts +++ b/src/video/state/providers/castingStateProvider.ts @@ -84,7 +84,7 @@ export function createCastingStateProvider( this.pause(); }, togglePictureInPicture() { - updateSource(descriptor, state); + // no picture in picture while casting }, async setVolume(v) { // clamp time between 0 and 1 diff --git a/src/video/state/providers/videoStateProvider.ts b/src/video/state/providers/videoStateProvider.ts index 8e100998..2d3fec1f 100644 --- a/src/video/state/providers/videoStateProvider.ts +++ b/src/video/state/providers/videoStateProvider.ts @@ -214,20 +214,12 @@ export function createVideoStateProvider( ? "inline" : "picture-in-picture" ); - state.interface.isPictureInPicture = - webkitPlayer.webkitPresentationMode === "picture-in-picture"; } if (canPictureInPicture()) { if (player !== document.pictureInPictureElement) { - try { - player.requestPictureInPicture(); - state.interface.isPictureInPicture = true; - } catch { - state.interface.isPictureInPicture = false; - } + player.requestPictureInPicture(); } else { document.exitPictureInPicture(); - state.interface.isPictureInPicture = false; } } }, diff --git a/src/video/state/types.ts b/src/video/state/types.ts index b1557d7f..6b04a55a 100644 --- a/src/video/state/types.ts +++ b/src/video/state/types.ts @@ -30,7 +30,6 @@ export type VideoPlayerState = { isFocused: boolean; // is the video player the users focus? (shortcuts only works when its focused) leftControlHovering: boolean; // is the cursor hovered over the left side of player controls popoutBounds: null | DOMRect; // bounding box of current popout - isPictureInPicture: boolean; // is picture in picture active }; // state related to the playing state of the media