Reputation: 2352
I have a page where users can listen to some songs, the songs are played with JavaScript so if you look at the page source you would see the full path to the songs and users can just download the song.
How can I deny access to those songs (.mp3) to everyone trying to access that file except for the JavaScript code on my page accessing it?
Upvotes: 0
Views: 159
Reputation: 17831
As JavaScript is executed on the client, and you need it to be able to download the mp3, your clients already essentially have the mp3 -- in their browser download cache folders.
You are probably better off encrypting the JavaScript or dynamically loading it afterwards. Nonetheless, if a client has somewhat of a knowledge about how it all works, he will still find the MP3.
Your only real option would be a new plugin for the browsers that plays the file you encrypted somehow.
If you deny access to *.mp3
files, your JavaScript will not be able to play the file, too.
Upvotes: 2