Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Picture in Picture mode on HTML5 video

Tags:

html5-video

How do you disable Picture in Picture mode on html5 videos?

Please note I'm not referring to this question which relates to Apple's AVKit

I know you can disable video download with controlsList="nodownload", how is it possible for Picture in Picture mode.

<video controls controlsList="nodownload">
  <source src="https://www.w3schools.com/html/mov_bbb.ogg" type="video/mp4">
  <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/ogg">
</video>
like image 588
Holly Avatar asked Jan 31 '19 10:01

Holly


People also ask

What is PIP HTML5?

The native Picture-in-Picture API allows you to create a floating, pinned HTML5 video that overlays on top of your workspace. This API is seamlessly integrated into the HTMLVideoElement interface and is super simple to use: <video id="vid" src="my-video.mp4"></video> <button id="pip-btn">Enter PIP</button>

How do I turn off picture in picture on my computer?

Go to the "Cookies and site permissions" section. Scroll down and find the "Picture in Picture control" option. As an option, you can use the e dge://settings/content/PictureInPicture URI in the address bar. Disable the "Show Picture in Picture control inside video frame" toggle option.

How to disable picture-in-Picture mode in Firefox?

Step 1: Launch Firefox and click the menu button in the upper-right corner. Then select Options in the drop-down menu. Step 2: In the General section, scroll down the page to the Browsing option. After that, uncheck Enable picture-in-picture video controls. Now, the Picture-in-Picture mode has been disabled successfully.

Why can't I display a video in HTML5?

Your browser does not support HTML5 video. To show a video in HTML, use the <video> element: Your browser does not support the video tag. The controls attribute adds video controls, like play, pause, and volume. It is a good idea to always include width and height attributes.

What does the htmlvideoelement disablepictureinpicture property do?

The HTMLVideoElement disablePictureInPicture property reflects the HTML attribute indicating whether the user agent should suggest the picture-in-picture feature to users, or request it automatically. A boolean value that is true if the user agent should suggest that feature to users.

How to show a video in HTML?

To show a video in HTML, use the <video> element: Your browser does not support the video tag. The controls attribute adds video controls, like play, pause, and volume. It is a good idea to always include width and height attributes.


3 Answers

per the spec at https://wicg.github.io/picture-in-picture/#disable-pip, the attribute to control this is disablePictureInPicture

<video controls disablePictureInPicture controlsList="nodownload">
  <source src="https://www.w3schools.com/html/mov_bbb.ogg" type="video/mp4">
  <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/ogg">
</video>

to achieve the same through javascript:

<video id="vid" controls muted>
<source src="https://www.w3schools.com/html/mov_bbb.mp4">
</video>
<script>
vid=document.getElementById("vid")
vid.disablePictureInPicture = true
</script>
like image 73
Offbeatmammal Avatar answered Oct 05 '22 18:10

Offbeatmammal


If you want to do it through JavaScript. This code applies for all videos on your page and it disables the download,take picture and right click context which also contains download option.

You may want to change jQuery to $ I wrote this code add it to my theme in WordPress to disable the download in all videos in my site.

jQuery('video').on("loadeddata", function() {
    jQuery('video').attr('controlsList', 'nodownload');
    jQuery('video').bind('contextmenu',function() { return false; });
    jQuery('video').attr('disablePictureInPicture', 'true');
}); 
like image 25
Shady Mohamed Sherif Avatar answered Oct 05 '22 20:10

Shady Mohamed Sherif


Use this:

<video controls disablePictureInPicture>

The disablePictureInPicture is a boolean flag that would disable picture in picture item in three dots menu.

like image 30
AmerllicA Avatar answered Oct 05 '22 18:10

AmerllicA