Fix type error, only show pip if pip is available

This commit is contained in:
Jip Fr 2023-10-21 20:17:18 +02:00
parent 78ae77392c
commit 294f31c567
3 changed files with 11 additions and 8 deletions

View File

@ -1,10 +1,16 @@
import { Icons } from "@/components/Icon";
import { VideoPlayerButton } from "@/components/player/internals/Button";
import { usePlayerStore } from "@/stores/player/store";
import {
canPictureInPicture,
canWebkitPictureInPicture,
} from "@/utils/detectFeatures";
export function Pip() {
const display = usePlayerStore((s) => s.display);
if (!canPictureInPicture() && !canWebkitPictureInPicture()) return null;
return (
<VideoPlayerButton
onClick={() => display?.togglePictureInPicture()}

View File

@ -15,7 +15,9 @@ import {
canChangeVolume,
canFullscreen,
canFullscreenAnyElement,
canPictureInPicture,
canWebkitFullscreen,
canWebkitPictureInPicture,
} from "@/utils/detectFeatures";
import { makeEmitter } from "@/utils/events";
@ -42,14 +44,6 @@ function hlsLevelsToQualities(levels: Level[]): SourceQuality[] {
.filter((v): v is SourceQuality => !!v);
}
export function canWebkitPictureInPicture(): boolean {
return "webkitSupportsPresentationMode" in document.createElement("video");
}
export function canPictureInPicture(): boolean {
return "pictureInPictureEnabled" in document;
}
export function makeVideoElementDisplayInterface(): DisplayInterface {
const { emit, on, off } = makeEmitter<DisplayInterfaceEvents>();
let source: LoadableSource | null = null;

View File

@ -179,6 +179,9 @@ export function makeChromecastDisplayInterface(
if (containerElement) fscreen.requestFullscreen(containerElement);
}
},
togglePictureInPicture() {
// Can't PIP while Chromecasting
},
startAirplay() {
// cant airplay while chromecasting
},