TIL Javascript and Picture-in-Picture

Published January 5, 2020

In a lot of sites, you can right click (sometimes twice) to see the "Enter in Picture in Picture" option. There are some sites like Netflix or Twtich does some DOM magic to prevent that.

Here's two javascript snippets I paste on the dev console so I can watch while working.

The safari one's the thing I just learned today!

# Safari

document.querySelector('video').webkitSetPresentationMode('picture-in-picture')

# Chrome

document.querySelector('video').requestPictureInPicture()

🌊 Huzah! You made it down here!