So, I made a combination of things that suit me ... although not entirely safe, it definitely helped me obscure this a bit.
First of all, I use AudioJS player to play music, which can be found at: http://kolber.github.com/audiojs/
Basically what I did was:
- Instead of using "data-src" as the path to my songs, I called it the "key" so that people do not always think that this is the way.
- Instead of using "my-song-title" as the name of the songs, I changed it to a number like 7364920 so that people could not search for it in the source and thus find the URL.
- I added + “mp3” to the javascript code after all the “key” variables, so I would not have to declare it in a private link.
- I used a relative path like "./8273019283/" instead of "your-domain.com/8273019283/", so it would be harder to say that I am displaying a URL.
- Added a link to iTunes in href so that people couldn’t understand how I pulled out the file.
So now my inline JavaScript looks like this:
<script type="text/javascript"> $(function() { // Play entire album var a = audiojs.createAll({ trackEnded: function() { var next = $("ul li.playing").next(); if (!next.length) next = $("ul li").first(); next.addClass("playing").siblings().removeClass("playing"); audio.load($("a", next).attr("key") + "mp3"); audio.play(); } }); // Load the first song var audio = a[0]; first = $("ul a").attr("key") + "mp3"; $("ul li").first().addClass("playing"); audio.load(first); // Load when clicked $("ul li").click(function(e) { e.preventDefault(); $(this).addClass("playing").siblings().removeClass("playing"); audio.load($('a', this).attr('key') + "mp3"); audio.play(); }); }); </script>
My link looks like this:
<a href="<?php $link = 'http://itunes.apple.com/us/album/falling/id504779876?i=504779883&uo=4'; $obfuscatedLink = ""; for ($i=0; $i<strlen($link); $i++){ $obfuscatedLink .= "&
When you download it in a browser and see the source code, you will see:
<a href="http://itunes.apple.com/us/album/falling/id504779876?i=504779883&uo=4" target="itunes_store" key="./8249795872/9273847591.">Falling</a>
Then, when you use Web Inspector or Firebug, you will see:
<a href="http://itunes.apple.com/us/album/falling/id504779876?i=504779883&uo=4" target="itunes_store" key="./8249795872/9273847591.">Falling</a> - *which doesn't completely give the url away
Essentially, I made the link look like an API key. The cool thing is that you can’t just copy the link directly from the source view or directly from Web Inspector / Firebug. It is not error protected and can definitely be broken, but the user must know what he is doing. This holds most people back, but still allows the player to get the URL needed to play the song :)
* Also, I got the php obfusticate script somewhere on the Stack Exchange, I just don’t know where.