MCPcopy Create free account
hub / github.com/code100x/cms / togglePictureInPicture

Function togglePictureInPicture

src/components/VideoPlayer2.tsx:65–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63 const vidUrl = options.sources[0].src;
64
65 const togglePictureInPicture = async () => {
66 try {
67 if (document.pictureInPictureElement) {
68 await document.exitPictureInPicture();
69 } else if (document.pictureInPictureEnabled && playerRef.current) {
70 playerRef.current.requestPictureInPicture();
71 }
72 } catch (error) {
73 // Ignore specific errors that might occur during normal operation
74 if (
75 error instanceof Error &&
76 error.name !== 'NotAllowedError' &&
77 error.name !== 'NotSupportedError'
78 ) {
79 console.error('Failed to toggle Picture-in-Picture mode:', error);
80 toast.error('Failed to toggle Picture-in-Picture mode.');
81 }
82 }
83 };
84
85 const PipButton = () => (
86 <button

Callers 2

createPipButtonFunction · 0.85
handleKeyPressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected