Martin Algesten Martin Algesten - 2 months ago 12
Javascript Question

How do I trigger picture in picture on Safari 10

Safari 10 introduces picture in picture. The button is there for html5 video standard controls, but how do I trigger it by javascript?

Apple says:


If you use custom HTML5 video controls, you can add Picture in Picture functionality using the JavaScript presentation mode API.


With no further references.

Answer

Use Javascript to activate the picture-in-picture mode. It will run by this way.

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