Last active
March 1, 2025 14:45
-
-
Save Rendez/6e088e8713f47e87ab04efcc22f365b1 to your computer and use it in GitHub Desktop.
TypeScript types for the Picture-in-Picture feature of the Document and the video tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface PictureInPictureResizeEvent extends Event { | |
readonly target: PictureInPictureWindow; | |
} | |
interface PictureInPictureWindow { | |
readonly width: number; | |
readonly height: number; | |
onresize(this: PictureInPictureWindow, ev: PictureInPictureResizeEvent): void; | |
addEventListener( | |
type: 'resize', | |
listener: EventListenerOrEventListenerObject, | |
options?: boolean | AddEventListenerOptions | |
): void; | |
removeEventListener( | |
type: 'resize', | |
listener: EventListenerOrEventListenerObject, | |
options?: boolean | EventListenerOptions | |
): void; | |
} | |
interface PictureInPictureEvent extends Event { | |
readonly pictureInPictureWindow: PictureInPictureWindow; | |
} | |
type PictureInPictureEventListener = ((this: HTMLVideoElement, ev: PictureInPictureEvent) => any) | null; | |
interface HTMLVideoElement { | |
autoPictureInPicture: boolean; | |
disablePictureInPicture: boolean; | |
requestPictureInPicture(): Promise<PictureInPictureWindow>; | |
onenterpictureinpicture: PictureInPictureEventListener; | |
onleavepictureinpicture: PictureInPictureEventListener; | |
} | |
interface Document { | |
readonly pictureInPictureEnabled: boolean; | |
exitPictureInPicture(): Promise<void>; | |
} | |
interface DocumentOrShadowRoot { | |
readonly pictureInPictureElement: HTMLVideoElement | null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment