Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to remove picture in picture in firefox using javascript or css?

I want to disable Picture in Picture feature for <Video> tag for my website due to some certification requirements but firefox does not allow to turn off. Any help would be appreciated.

  • Firefox uses a shadow-root with {mode:"closed"} to forcefully display Picture in Picture toogle (See the image).
  • Firefox also not supporting Picture-in-Picture API - check this link

Note: I have also added disablePictureInPicture attribute but still it's not working for firefox.

 <video width="400" src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" controls  disablePictureInPicture></video>
like image 610
Rohit Patel Avatar asked Jan 21 '20 10:01

Rohit Patel


People also ask

How to disable picture-in-picture feature in Firefox?

You’ll see “ Enable picture-in-picture video controls ” option. The option is enabled by default i.e. Picture-In-Picture feature is activated in Firefox. Uncheck the option to deactivate and disable Picture-In-Picture feature. Now you’ll no longer see Picture-In-Picture icon while playing a video on any web page.

How to delete an image in JavaScript?

To delete an image in JavaScript (or generally to delete anything), first you should grab the element, then traverse to its parent element, then you can delete the child using removeChild method. when you want to show the image.

How to close or detach a video in Firefox?

If you hover mouse cursor over the icon, it’ll convert into a big blue icon showing “ Picture-in-Picture ” text as shown in following screenshot: Click on the “Picture-in-Picture” icon and Firefox will launch or detach the video in a separate floating window which contains a big “Close” button.

How do I delete an image from a child element?

To delete an image in JavaScript (or generally to delete anything), first you should grab the element, then traverse to its parent element, then you can delete the child using removeChild method. Show activity on this post. when you want to show the image. Show activity on this post.


2 Answers

Videos without audio do not have the picture in picture button in firefox. This will not work for all use cases, but it might be useful in some situations. If you really depend on it and having audio you could try using a separate audio tag, but that could result in desynchronization issues.

You can do this e.g. using ffmpeg like described in this question.

like image 121
zuim Avatar answered Oct 18 '22 11:10

zuim


As far as I know, there is currently (as of Firefox 72) no option for website authors to disable the button. Only users can hide it via the Firefox settings.

Though a request to add an API was created just a few hours ago.

like image 25
Sebastian Zartner Avatar answered Oct 18 '22 09:10

Sebastian Zartner