Skip to content

Commit

Permalink
Handle enterpictureinpicture media session action
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed Oct 16, 2023
1 parent 2bb27d9 commit 92b1d7a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions media-session/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ try {
log('Warning! The "seekto" media session action is not supported.');
}


/* Enter Picture-in-Picture (supported since Chrome 120) */

try {
navigator.mediaSession.setActionHandler('enterpictureinpicture', async function(event) {
log('> User clicked "Enter Picture-in-Picture" icon.');
await video.requestPictureInPicture();
});
} catch(error) {
log('Warning! The "enterpictureinpicture" media session action is not supported.');
}

/* Utils */

function getAwesomePlaylist() {
Expand Down

0 comments on commit 92b1d7a

Please sign in to comment.