How to remove video download option

Asked

Viewed 3,864 times

2

I would like to remove the video download options (I know this will not prevent downloading it through other means. But the idea is just to make it harder for more lay users).

I have the following example: https://jsfiddle.net/n0ng38eo/

Where through CSS I can hide the video download button.

But in case the user right-click, it still has the option to download the video:

inserir a descrição da imagem aqui

I would like to remove this option also via javascript or some kind of HTML configuration.

2 answers

2


I found a solution: https://jsfiddle.net/u1wqb4kz/

// Remove botão de download de vídeos
video::-internal-media-controls-download-button {
    display:none;
}

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

video::-webkit-media-controls-panel {
    width: calc(100% + 30px); /* Adjust as needed */
}
<video src="http://html5demos.com/assets/dizzy.mp4" oncontextmenu="return false;" controls></video>

I used one of the answers on this page from stackoverflow

  • Okay, so he enters the page with Google Chrome, displays the source code, clicks on the video link and the infamous little window appears for him to download.

  • @Leocaracciolo in the question I said that the idea was not impelling to download the video. Until pq this is practically impossible. As sophisticated as q was the method I could use a program and record it when it was playing on screen. I just wanted to disable this option for laypeople. In the link of stackoverflow q I found the solution, there are more advanced methods as well. But for q I needed it sufficed.

  • I understood, but the ideal then would be to prevent laypeople, little laypeople, more or less laypeople and laypeople. Leave the gap only for smart users! My answer covers every class. :)

  • I edited the answer and brought the code here, if one day jsfiddle goes offline for maintenance, attack or old urls are removed you will have the security of the code be safe in the answer as well. + 1 for your answer

2

Since it is to make it difficult beyond the author’s own solution, one can put this script that inhibits mouse right and much more.

function bloqueia_mouse_teclado() {

        // CTRL V v
        $(document).ready(function() {
            $(document).keydown(function(event) {
                if (event.ctrlKey == true && (event.which == '118' || event.which == '86')) {
                    event.preventDefault();
                }
            });
        });

        // CTRL C c
        $(document).ready(function() {
            $(document).keydown(function(event) {
                if (event.ctrlKey == true && (event.which == '97' || event.which == '67')) {
                    event.preventDefault();
                }
            });
        });

        // CTRL U u
        $(document).ready(function() {
            $(document).keydown(function(event) {
                if (event.ctrlKey == true && (event.which == '85' || event.which == '117')) {
                    event.preventDefault();
                }
            });
        });

        // CTRL A a
        $(document).ready(function() {
            $(document).keydown(function(event) {
                if (event.ctrlKey == true && (event.which == '65' || event.which == '97')) {
                    event.preventDefault();
                }
            });
        });

        // CTRL S s
        $(document).ready(function() {
            $(document).keydown(function(event) {
                if (event.ctrlKey == true && (event.which == '83' || event.which == '115')) {
                    event.preventDefault();
                }
            });
        });

        // CTRL X x
        $(document).ready(function() {
            $(document).keydown(function(event) {
                if (event.ctrlKey == true && (event.which == '88' || event.which == '120')) {
                    event.preventDefault();
                }
            });
        });

        // CTRL J j
        $(document).ready(function() {
            $(document).keydown(function(event) {
                if (event.ctrlKey == true && (event.which == '74' || event.which == '106')) {
                    event.preventDefault();
                }
            });
        });



        // Bloquear botão direito do mouse
        $(document).bind("contextmenu", function(e) {
            return false;
        });
    }


    bloqueia_mouse_teclado();
// Remove botão de download de vídeos
video::-internal-media-controls-download-button {
    display:none;
}

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

video::-webkit-media-controls-panel {
    width: calc(100% + 30px); 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<video src="http://html5demos.com/assets/dizzy.mp4" oncontextmenu="return false;" controls></video>

  • In addition to blocking the right mouse button. What else this script blocks?

  • in the code itself has the comments of what it inhibits. This oncontextmenu="Return false; property seems not to work in Opera

Browser other questions tagged

You are not signed in. Login or sign up in order to post.