Is it possible to prevent downloading of audio / video

Is it possible to prevent downloading of audio / video

by Birgit Scott -
Number of replies: 23

Dear Friends,

I'm a new, quite inexperienced admin for a library site featuring audios (.mp3) and videos (.flv). The files are from the Moodle repository on the server, linked to (not copied into Moodle) and displayed embedded.

I've managed to prevent downloading of them by disabling the right-click feature for the entire site.

Now it turns out that mobile phones give the user the download option instead of streaming them. Is there some way that I can block that?

Thank you smile

Average of ratings: -
In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Birgit,

that's an interesting question, there is a workaround to solve this but first of all I'd like to let you know that disabling the right-click feature is not secure at all (there are tons of extensions in the browser or ways to be able to download the complete list of resources linked in a page).

If you are embedding the resources, what you can do is instead embedding local files in your Moodle is embed files using a direct link.

The app only download resources embedded if they are served by Moodle, so, if you embed a file using an absolute URL the file won't be downloaded.

This will work only if you are embedding the files in pages, labels, books or in any activity in the description.

Juan

Average of ratings: Useful (1)
In reply to Juan Leyva

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Hi Juan,

Thank you for alerting me about the right-click!

I'm not sure I understand the "direct link" or "absolute URL". I have the files in a repository folder in my Moodle folder on a private server, so (to my knowledge) I cannot link to them directly, or?

If I upload them to a Youtube account for example, I would share private files via email. Do you mean that I could assign an email-id for the moodle site?

In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Hi Juan,

I tried now to link to a file directly on the server. I have copied the path from Moodle's automated backups, which I know works.

Linking in the description box, though, seems to work a little different. It adds the normal "http://etc.etc./(path)" in front of the "path" and I therefore get the following error code in the flowplayer:

200, Stream not found, NetStream.Play.StreamNotFound, clip: '[Clip] 'http://etc..

Could you give me an example of how it should look or to work around this? 

Thank you! smile

In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Birgit,

can you create a course in your site and grant me access as an editing teacher to that course so I can create an example for you?

If that's possible, please send me the credentials to mobile@moodle.com

Juan

In reply to Juan Leyva

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Hi Juan,

Yes! Thank you for sharing.

To be able to post questions in a developer's forum and connect to your knowledge is really helpful.

I've sent you credentials to the above email. Please let me know if I need to do something more.

Birgit

In reply to Juan Leyva

Re: Is it possible to prevent downloading of audio / video

by Dana Damoc -

Hi Juan, I have the same problem as Birgit.

My courses are formed of mainly video lessons and anyway I try to upload them (by uploading a File, by embedding the link in a Label or by using an external url) they can be downloaded with the right click. Can you advise.

Even if it's not the most effective way I would want to disable the right click also. Where can I paste the JavaScript for this?

I use Moodle 3 and the uploaded files are in MP4 format.

Thanks, Dana

In reply to Dana Damoc

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Hi Dana,

I'm so happy we are 2 people now requesting an option to prevent this smile

Here's the disabling of the right-click:

In Site Administration / Appearance / Additional HTML you paste:

<script language=JavaScript>

<!--

//Disable right mouse click Script

//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive

//For full source code, visit http://www.dynamicdrive.com

var message="This function has been disabled!";

///////////////////////////////////

function clickIE4(){

if (event.button==2){

alert(message);

return false;

}

}

function clickNS4(e){

if (document.layers||document.getElementById&&!document.all){

if (e.which==2||e.which==3){

alert(message);

return false;

}

}

}

if (document.layers){

document.captureEvents(Event.MOUSEDOWN);

document.onmousedown=clickNS4;

}

else if (document.all&&!document.getElementById){

document.onmousedown=clickIE4;

}

document.oncontextmenu=new Function("alert(message);return false")


// --> 

</script>

Moodle is great,

Birgit

Average of ratings: Useful (1)
In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Dana Damoc -

Hi Birgit,

Thanks a lot for the reply smile

Disabling the right click works fine. As for preventing the download in other ways was there any progress?

Cheers, Dana

In reply to Dana Damoc

Re: Is it possible to prevent downloading of audio / video

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi,

if you want this functionality supported in the Mobile app you should open a new issue (New feature) in the Moodle Tracker (in the MOBILE PROJECT) https://tracker.moodle.org/projects/MOBILE and vote for it.

Alternatively, you can ask (and pay) a Moodle partner to implement this, they can contact with us and we can suggest them how to implement it.

Regards, Juan

In reply to Juan Leyva

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Hi Juan,

My login for the link

https://tracker.moodle.org/projects/MOBILE

doesn't work. Shouldn't it be the same as for Moodle.docs?

I would very much like to post the functionality of mobiles preventing downloads of audio and video files.

Thank you so much for your advice.

Birgit

In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Dave Perry -
Picture of Testers

Tracker is a different login to the moodle.org / forums site. Which is a shame, but I assume it's a time thing of hacking the tracker software to handle moodle logins.

Something for HQ to answer on why that's not been done as I do find it a nuisance needing a separate login.

In reply to Dana Damoc

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Hi Dana,

I'm so happy it worked! smile

As you might have guessed by now, the downloading issue wasn't solved. Juan Leyva sent this response to my email:

Moodle assumes that if you add content in the platform everyone can access or download it, so, the only ones who are working on this type of solutions I imagine are private companies implementing systems for protecting contents.

Once of the features of the Mobile app is make possible to access all the content offline, so in this case I think that the app is not suitable for your needs.

You'd need a custom version of the app with this feature disabled, so only the contents are viewable when you are connected (please, note that in some countries this a problem because of the connectivity problems)

I have now created a request on Moodle Tracker that this be fixed Please sign in and vote for it being worked out. The NPO I'm working for hasn't got the means to pay for this being corrected. And frankly I think that would be a huge improvement for Moodle in general, if it was solved!

In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Disabling right click as a way of preventing downloading of content is not an effective solution. It will only take a mildly interested student a few seconds on Google to find a work around and once one student knows, all students know.

In reply to Marcus Green

Re: Is it possible to prevent downloading of audio / video

by Dana Damoc -

Dear Marcus Green,

That was already established if you would have read all the thread before stating the obvious !!!

In reply to Marcus Green

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Dear Marcus,

Thank you for alerting us to this. smile

I think it's a good point to make and it only makes the issue of Moodle itself protecting its repository much clearer.

To assume that everything posted should be available for all is quite an assumption to make. I don't even think that the statement is correct. 

Would you please vote for this being corrected?

All the best,

Birgit 

In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Derek Chirnside -

Birgit, you have misread Marcus.

He said (if I am correct) "assume everything posted will be downloadable by someone who does a little sleuthing".

Here is one reference, selected at random from Google: http://www.mediacollege.com/video/streaming/protect/

Think of it this way.  To see it it must be ON your computer monitor - and therefore in some form on your CPU.  (Right?) therefore it can be captured, somehow.

Someone will of course correct me if this is wrong.

I remember a few years back my student helper coming in to work looking a little tired, saying the new encryption on the lecture videos took a bit of extra work to break this year, that he had hidden his laptop under some pillows in the library, while he slept and the script he had written to download the stuff took 6 hours to download all he wanted.

-Derek



Average of ratings: Useful (1)
In reply to Derek Chirnside

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Yes, I know that true computer geniuses can do whatever they want. I even admire such a level of skill.

I just think there must be some measure in between that and being presented with the option to download by simply clicking play!

In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Toshihiro KITA -
Picture of Plugin developers Picture of Translators
FYI, if you want to disable right clicking only on Video-JS player (default player), edit like the following patch:

--- media/player/videojs/classes/plugin.php.orig 2017-12-13 15:41:47.518362037 +0900
+++ media/player/videojs/classes/plugin.php 2017-12-13 15:46:06.822500996 +0900
@@ -171,7 +171,8 @@
            // Create <video> or <audio> tag with necessary attributes and all sources.
            // We don't want fallback to another player because list_supported_urls() is already smart.
            // Otherwise we could end up with nested <audio> or <video> tags. Fallback to link only.
-            $attributes += ['preload' => 'auto', 'controls' => 'true', 'title' => $title];
+          //$attributes += ['preload' => 'auto', 'controls' => 'true', 'title' => $title];
+            $attributes += ['preload' => 'auto', 'controls' => 'true', 'title' => $title, 'oncontextmenu' => 'return false' ];
            $text = html_writer::tag($isaudio ? 'audio' : 'video', $sources . self::LINKPLACEHOLDER, $attributes);
        }

# I tested this on Moodle 3.2.
Average of ratings: Useful (1)
In reply to Toshihiro KITA

Re: Is it possible to prevent downloading of audio / video

by Toshihiro KITA -
Picture of Plugin developers Picture of Translators
...and in addition, the URL of videos and '<video>' tag are hidden (encoded)  in the HTML source, by this patch also for media/player/videojs/classes/plugin.php :

@@ -185,7 +186,8 @@
            }
        }

-        return html_writer::div($text, 'mediaplugin mediaplugin_videojs');
+        return html_writer::div("<script>document.write(decodeURIComponent(escape(atob('".base64_encode($text)."'))));</script>", 'mediaplugin mediaplugin_videojs');
+        // return html_writer::div($text, 'mediaplugin mediaplugin_videojs');
    }

    /**

# Of course, it will be just a little bit of prevention from downloading...
In reply to Toshihiro KITA

Re: Is it possible to prevent downloading of audio / video

by Birgit Scott -

Thank you so much! This is very helpful.

In reply to Toshihiro KITA

Ynt: Re: Is it possible to prevent downloading of audio / video

by Çetin Özyurt -

Thanks for the post. It worked like a charm. Thank you

In reply to Toshihiro KITA

Re: Is it possible to prevent downloading of audio / video

by wz z -
@Toshihiro Thank you very much! It works like a charm!
However, on the video inserted by the "Insert or edit an audio/video file" button on any Atto editor, users can still right click.

I tried editing the media/classes/manager.php file, replace the following file:
$out = html_writer::tag('div', $out, array('class' => 'resourcecontent'));
with:
$out = html_writer::tag('div', $out, array('class' => 'resourcecontent', 'oncontextmenu' => 'return false'));

No luck.
In reply to Birgit Scott

Re: Is it possible to prevent downloading of audio / video

by Dennis Maloney -

Thank you for the information on disabling the right click function. I spent the better part of a day trying to figure out how to disable the right click function in the site admin, edit settings and the moodle docs for 3.2...

Thanks

-Dennis