Disable media download in onebox

hello, I saw there is an option to disable audio download:

<audio controls #{@options[:disable_media_download_controls] ? 'controlslist="nodownload"' : ""}>

at onebox/audio_onebox.rb at main · discourse/onebox · GitHub

and

disable_media_download_controls: SiteSetting.disable_onebox_media_download_controls,

at discourse/oneboxer.rb at 03998e0a299b7ae89678e2854e3abf84bd6ef132 · discourse/discourse · GitHub

So I tried to write it using

./launcher enter app
rails c
SiteSetting.disable_onebox_media_download_controls=true

and also here

vi containers/app.yml
under params:
disable_media_download_controls: true
disable_onebox_media_download_controls: true
under env:
DISCOURSE_DISABLE_ONEBOX_MEDIA_DOWNLOAD_CONTROLS: true

but still audio can be downloaded through the onebox’s “download” option. Anyone can help? many thanks.

1 Like

I don’t know, but how should one listen audio if download is disabled?

there is a download option if you click the three dots at the end: see picture from this post:

What I want is that the explicit download option is hidden/disabled, while people can still use this to listen to the audio.

I still don’t get it. Discourse can’t streaming so audiofile must be downloaded for listening. Or am I totally wrong?

Or do you accept downloading when a user doesn’t know they are downloading because one’s device doesn’t ask where it should save?

Yet, that audio is possible to save anyway via recording :wink:

Sorry — I don’t help a bit but I would like to understand why, what, where and everything :rofl:

My very weak point is that kind disabling attempts are succesfully rarely, Or needed. But fine if it is doable.

1 Like

if you allow explicit download option, then the audio/video content could be stored/used/commercialised elsewhere, where such intellectual property may not be authorised properly. So it is probably wise to make the default option to disable the explicit download option.

Can you advise how to achieve that in the setting/code level. thanks.

It’s not something I’ve used, but is anything in this topic any help?

1 Like

As far as the website (using discourse) itself is concerned, it is important to avoid any future IP-related issue. Even if the author use a TC or some sort of theme, any infringement of the IP could make the website liable for potential damage etc. Even if the website may seem to have nothing to do with it, just because it acts as a channel of exchange, some lawyer may have other thoughts.

So to disable explicit download option should be quite useful, as you wouldn’t see such option on most of the big websites like youtube. Can anyone help with the code/setting to make it happen please.

1 Like

After that, you will need to rebake or edit the post with the local audio. Have you tried that?

1 Like

how to rebake or edit the post?

Click on the post button, then on the :wrench: button and finally on “Rebuild HTML”

“Rebuild HTML” done, but still have the “Download” option.

Let’s test this:

![614107_11861866-lq|audio](upload://jq0kR3R4YPrn1kM48EL33oVgjT8.mp3)

https://d11a6trkgmumsb.cloudfront.net/original/3X/8/8/8819dba2a51ca9f987e93d64dfe823161141d0f6.mp3

second one works (no download option), but first one still have.

Oh I see, the site setting only affect onebox, so only the second type of audio, not the first one because it isn’t technically a onebox.

What else needs to be done to make the first case work?

1 Like

If you want to dive into the code it’s coming from

You will need to receive the site setting on that context somehow and handle it.

2 Likes

As a hard code quick fix, I tried:

./launcher enter app
vi app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js

and append

controlsList="nodownload"

to
<audio preload="metadata" controls>

and

./launcher restart app

but still have Download option. Should I rebuild app?

That wouldn’t work as the JS is compiled by our rather complicated asset pipeline.

If you want a quick and hacky solution, a theme-component that listens to our decoratedCooked callback and changes the audio element is your best bet. You can learn about it on Developer’s guide to Discourse Themes

1 Like