Video.js: How to enable picture in picture mode for safari?

Created on 12 Jun 2017  路  8Comments  路  Source: videojs/video.js

I want to enable picture in picture placeholder for video for IOS devices.
I have tried this code

$("video").webkitSetPresentationMode("picture-in-picture");

This works on plan simple html5 player but it is not working with videojs.
I have tried to trigger code with fullscreen button but still not working.

This is demo code,

Steps to reproduce

  1. Play video on Iphone or Ipad.
  2. Go full screen and click picture in picture button ( beside exit fullscreen button)
  3. it wont fill video spot on webpage with place holder.

Results

Expected

when I play video in (picture in picture) mode there should be placeholder on video's original location.
pip

Actual

Video tag location is not showing anything at all.

Additional Information

what browser are affected?
Safari 10 +

what platforms (operating systems and devices) are affected?
IOS

Most helpful comment

Your example won't work for a few reasons. You're using jQuery without having the jQuery library loaded, and trying to go to picture in picture too early - Safari will only allow PIP mode after the video has started.

You need to call webkitSetPresentationMode() on the tech el - the video element after the player has initialised, e.g.

  player.one('playing', function() {
    var techEl = player.tech(true).el();
    if (techEl.webkitSupportsPresentationMode && typeof techEl.webkitSetPresentationMode === "function") {
      techEl.webkitSetPresentationMode('picture-in-picture')
    }
  });

example

All 8 comments

Safari triggers a webkitbeginfullscreen event when it enters pip mode, which caused us to add fullscreen styling to the inline placeholder. Those styles prevent the placeholder being visible. This is fixed is 6.2.1

Hi, thanks for the response. Is there any way i can get 6.2.1 js and css file without getting uncompiled files ? like minified just two files (js and css), I have search all over but all cdn, codepen or demo includes older version. Thanks,

Looks like the 6.2.1 zip didn't get uploaded to github releases properly. Just updated it. https://github.com/videojs/video.js/releases/tag/v6.2.1

Thanks gkatsev 馃憤

@sohrabzia does everything work now? If so, can you close this issue. Thanks!

sorry for the late response, I have tried v6.2.1 but it doesnt seem to be working. here is Demo

edit: link updated

Your example won't work for a few reasons. You're using jQuery without having the jQuery library loaded, and trying to go to picture in picture too early - Safari will only allow PIP mode after the video has started.

You need to call webkitSetPresentationMode() on the tech el - the video element after the player has initialised, e.g.

  player.one('playing', function() {
    var techEl = player.tech(true).el();
    if (techEl.webkitSupportsPresentationMode && typeof techEl.webkitSetPresentationMode === "function") {
      techEl.webkitSetPresentationMode('picture-in-picture')
    }
  });

example

I guess this is different from the Picture-in-Picture API (https://googlechrome.github.io/samples/picture-in-picture/) that is available since Chrome 70+. Can this be supported? New ticket?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uikoo9 picture uikoo9  路  4Comments

zhulduz picture zhulduz  路  3Comments

pblasi picture pblasi  路  3Comments

SolmazKh picture SolmazKh  路  4Comments

onigetoc picture onigetoc  路  4Comments