Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide only Picture in Picture (PiP) control from safari

I need to hide only one video control from safari browser which is Picture in Picture (PiP). Is there is any solution for that ?

Can we hide this using HTML5?

like image 716
M.Bains Avatar asked Mar 01 '18 04:03

M.Bains


2 Answers

disablePictureInPicture attribute can be used for that now

<video disablepictureinpicture controlslist="nodownload"></video>

details here: https://wicg.github.io/picture-in-picture/#disable-pip

like image 143
Andrii Bogachenko Avatar answered Sep 18 '22 02:09

Andrii Bogachenko


There doesn't seem to be any official way to do it...

Currently in Safari it's all or nothing (with controls=false).


The shadow-targetting pseudo elements selectors doesn't seem to work on this browser, unlike on Blink browsers, and even though I found references of an ::-webkit-media-controls-picture-in-picture-button on the Internet.


So for today, the only solution is to disable all the default controls of your video element and to build you own controls.
If you wish, you can make it conditional though:

if(typeof vidElem.webkitSupportsPresentationMode === 'function' &&
  vidElem.webkitSupportsPresentationMode('picture-in-picture') ) {
    vidElem.controls = false;
    buildCustomControls(vidElem);
}

For the future, there might a controlsList attribute, which drafts specs currently only handles nodownload, nofullscreen and noremoteplayback, but I can't see why a nopicture-in-picture couldn't make its way there, if this attribute (mainly motivated by Blink browsers, once again) ever gets out of the drafts.

like image 42
Kaiido Avatar answered Sep 21 '22 02:09

Kaiido