Encrypt audio url to block access to the mp3 resource

0

I have a list of audios and two types of users. Some can [play] and others [play and download].

The audios charge them dynamically after a query to the BD and I show them with the following code:

<audio controls="controls" controlsList="nodownload">
    <source src="~/2018/05/11/test.mp3" type="audio/mpeg" />
    Your browser does not support the audio element.
</audio>

When the user can download the audio too, I just remove controlsList="nodownload" .

The user who can only play the audios can see the source code of the page and get the audio link src="/ 2018/05/11 / test.mp3 , open it and download it or with the developer tools remove the controlsList .

Everywhere I see it this is wrong.

I have been researching and should encrypt my audio url so that the user can not access the file directly

Has anyone had a similar need, some advice or recommendation?

I can not think of how to solve this, my only light is the following link: link but I do not understand how to implement that and if it is similar in audios.

    
asked by Jorge López 16.05.2018 в 01:43
source

1 answer

0

Right now what I can think of, if you are using Apache as a web server, you could use a .htaccess file to restrict access to any file with an .mp3 extension

In the English forum you have this answer to guide you.

    
answered by 16.05.2018 в 16:45