Safari HTML5 custom video controller with Picture In Picture (PiP)
At the WWDC15 Apple introduces Safari 9 (Safari 10 for MacOS), there now have support for Picture in Picture.
However, they just say:
If you use custom HTML5 video controls, you can add Picture in Picture functionality using the JavaScript presentation mode API.
but not telling how or where to find its documentation.
The default video controller has the button, but how do I trigger it by javascript?
First if you are looking for making Picture in Picture in Chrome then see this link
Add a Picture-in-Picture Element to Your Markup
The custom controls now include markup for a new picture-in-picture button, which is visible by default.
Listing 1 This markup adds a picture-in-picture button
Add Functionality to the Button
Add a function to toggle Picture in Picture using the webkitSetPresentationMode property from the presentation mode API.
Listing 2 This code toggles Picture in Picture using a click event listener.
Resource
In action.