22

i want to disable download video link from control panel of video tag.


     <video oncontextmenu="return false;" id="myVideo" autoplay controls>
        <source src="uploads/videos/<?php echo $vid;?>" type="video/mp4">
    </video>
nik
  • 265
  • 1
  • 3
  • 10
  • Possible duplicate of [Prevent HTML5 video from being downloaded (right-click saved)?](http://stackoverflow.com/questions/9756837/prevent-html5-video-from-being-downloaded-right-click-saved) – iHasCodeForU Dec 16 '16 at 09:49
  • using oncontextmenu="return false;" i can disable right click but we have download link in video control bar..near volume control button.i want to disable that – nik Dec 16 '16 at 09:53
  • Which video player you are using? – keerti Dec 16 '16 at 10:27
  • using browser to run video from video tag source – nik Dec 16 '16 at 10:41
  • Not a duplicate the answer below by Mathankumar K helps answer it correctly. – saNiks Jul 26 '17 at 14:54

3 Answers3

42

That's very easy it seems that your using the HTML 5 Video and using your sample above, below is the code:

<video oncontextmenu="return false;" id="myVideo" autoplay controls controlsList="nodownload">
    <source src="uploads/videos/<?php echo $vid;?>" type="video/mp4">
</video>

Just add controlsList="nodownload" in your video tag.

Allan
  • 630
  • 7
  • 7
4

Add below style to disable download link in video tag.

For Example:

<!DOCTYPE html>
<html>
<head>
<style>
   video::-internal-media-controls-download-button {
    display:none;
   }

   video::-webkit-media-controls-enclosure {
        overflow:hidden;
   }

   video::-webkit-media-controls-panel {
        width: calc(100% + 30px); 
   }
</style>
</head>

<body>

<video width="320" height="240" controls>
  <source src="add your video url" type="video/mp4">
</video>
</body>
</html>
Mathankumar K
  • 621
  • 1
  • 6
  • 14
  • Thank you been searching for it all over but they always redirected me to the other questions – saNiks Jul 26 '17 at 14:53
2

For anyone that may be looking at this question from the future (Jetsons type beat) yes, controlList='nodownload' absolutely work. But I would suggest, instead of adding controlList in the video tag, do it in your js file. Because if someone starts playing around with your code, they could easily delete the controlsList property and still download it (if they are on a computer of course) So, to be safe - put it in your js file. Then obfuscate the js file. So, just in case you don't know what I mean - it should look like this (btw, I used jquery):

$(document).ready(() => {

$('video').attr('controlsList', 'nodownload');

});

And this will absolutely work and prevent people from just going in and deleting your video properties.

Dre Jackson
  • 771
  • 10
  • 18