7

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.

Martin Algesten
  • 13,052
  • 4
  • 54
  • 77

2 Answers2

16

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

document.querySelector("video").webkitSetPresentationMode("picture-in-picture")
Li Hanyuan
  • 506
  • 1
  • 4
  • 7
0

This question already have been asked

Anyways see this

Here is Safari's API

And I also have a How to PiP video in HTML5

Check support

webkitSupportsPresentationMode

Set Mode

webkitSetPresentationMode
TheCrazyProfessor
  • 919
  • 1
  • 15
  • 31