I am developing a shopping cart in PHP where i will sell the Songs in MP3 format. With product display i would like to provide the visitors/users to listen the Song 1 time only. So if i use players like JW player to play the song. The player disclose the file path in the source code of the web page and they can download the file directly.
What i am looking for it to play the song so that visitors does not know the path of the song file.
How can i avoid this ? Please advice.
Thanks
You are asking for a DRM system. Such thing does not exist.
Rationale:
- Alice wants to send a message (MP3 file) to Bob
- Alice does not want Eve to get the message (MP3 file)
- Bob and Eve are the same person
This is what DRM is trying to solve. All you can do is try to hide the fact from the end user. Good luck with that...
(In the above example you can replace "Alice" with "server", "Bob" with "site visitor" and "Eve" with "an user that wants to download the file without paying for it".)
If you accept that you can't have DRM system, there're more possibilities:
- Send only a fragment of the file to the user until they have payed for it
- Destroy/watermark the sample file (e.g. at 15 seconds into the playback, the MP3 file contains recording "This is a demo version of the song, actual purchased song will not contain this message".
Note that you must have the sample file different from actual file you're selling. That's the only way to fix the problem of user getting the actual file before paying for it.
You cant.
While you can obscure the URL, you cannot prevent people from downloading the songs for free. It's just not how HTTP works. If you provide a URL, no matter if obscured or not, it will ultimately have to respond with the data to play. Otherwise, JWPlayer wont be able to play the data.
Since JWPlayer is embedded into the website, it has to make a request to some backend server serving the data. These requests can be intercepted easily and it will only be a matter of days until people figure out they can download full albums for free.
Hence, if you want to make sure you are not ruining the shop, either provide low quality mp3s (which might give a bad listening experience and not convince people to buy them) or provide previews of the songs (like almost everyone else does).
Create a page that serves up the MP3 file based on some random string that gets passed in the URL. Each random string is stored in a database table, with reference to the real file location. Once the song is listened to once, flip a status field in the database to prevent that random string to be used again.
You don't have to worry about disclosing the real path of the file, because even if the user checked the source code, they would just see the random string.
Also, you should do the same type of thing for downloads. Require the user to be logged in, and instead of a direct path to the file, pass it through a php page so that the link to the file isn't "out there" for anyone to grab/use.
So basically, what you want to achieve is to provide the buyer with a "sample" of the song that he is about to buy.
After listening to the sample, he can then buy the full song.
In my opinion you could follow 2 paths here:
Chop up ever song into a small sample of for example 1 minute and let them hear only that.
If the user succeeds in downloading that, there is no problem because he will not be in possesion of the full song. You can do this automatically server side by using an mp3 encoder/decoder like FFMPEG to create the small samples for you.
Since Flash works really well with streaming audio/video, you could use an on-demand streaming mechanism that will also provide the user with a sample of your song. This way you would only send the bytes of the sample to the client, not the full song. This can be achieved by using open source media server technologies like Red5
Though option 2 is probably the most solid solution, it will also be the most time intensive one and the hardest to achieve.
Many online music stores do the same thing. They only give you a limited preview.
Here are some that I know of:
- https://www.beatport.com/ is currently a flex music store that also uses the streaming on demand principle to give you limited previews.
- http://www.trackitdown.net/ is an Html/AJAX based music store.
Cheers