JavaScript - exitPictureInPicture() method

revision:


Category : document

The Document method exitPictureInPicture() requests that a video contained in this document, which is currently floating, be taken out of picture-in-picture mode, restoring the previous state of the screen. This usually reverses the effects of a previous call to HTMLVideoElement.requestPictureInPicture().

Syntax :

        exitPictureInPicture()
    

Parameters: none

Examples:

            document.onclick = (event) => {
                if (document.pictureInPictureElement) {
                  document
                    .exitPictureInPicture()
                    .then(() => console.log("Document Exited from Picture-in-Picture mode"))
                    .catch((err) => console.error(err));
                } else {
                  video.requestPictureInPicture();
                }
            };
        

Practical examples

example: use on video element.

example: use on video element

code:
                    
                

example:
code:
                    
                

example:
code: