In order to use HTML5 features to play an MP3 file the browser would need to know the URL to the MP3 file, and therefore it would need to be included in the the source code. There are some tricks however that can help make it more difficult for people to find the URL, such as:
Obfuscating the URL using HTML character code substitutes
For example: http:// would become http://
<?php
function HtmlObfuscation( $sText ) {
$sObfuscated = '';
for( $i = 0; $i < strlen( $sText ); $i++ ) {
$sObfuscated .= '&#' . ord( $sText[$i] ) . ';';
}
}
Inserting the URL after the page has loaded using Javascript
HTML file would contain:
<audio controls id="mp3-player"></audio>
<script type="text/javascript" src="https://webmasters.stackexchange.com/questions/76000/mp3-player.js"></script>
and then the javascript file mp3-player.js could contain:
oMp3Player = document.getElementById('mp3-player');
oAudioSource = document.createElement('source');
oAudioSource.href="http://www.example.com/audio/protected-asset.mp3";
oAudioSource.setAttribute('href', 'http://www.example.com/audio/protected-asset.mp3');
oMp3Player.appendChild(oAudioSource);
or perhaps an obfuscated version of the same (created using an online tool):
eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('a=2.d(\'1-c\');0=2.h(\'g\');0.6=\'4://3.7.5/8/b-9.1\';0.f(\'6\',\'4://3.7.5/8/b-9.1\');a.e(0);',18,18,'oAudioSource|mp3|document|www|http|com|href|example|audio|asset|oMp3Player|protected|player|getElementById|appendChild|setAttribute|source|createElement'.split('|'),0,{}))
Slow stream
Restrict the data speed of the stream to listening pace so that it wouldn’t be possible to download an MP3 file quicker than it would take to listen to it.
Examples:
http://priteshgupta.com/2011/07/limit-file-download-speed-using-php/
https://stackoverflow.com/questions/4002106/limit-download-speed-using-php
Whatever tricks you use though to hide it in the source code, the browser will often reveal it in very easy readable format if the developer tools are enabled and the Network tab selected. All the top browsers have these features built-in these days by just pressing F12.
Also, unfortunately if you use HTML5 for embedding the MP3 audio link you’ll find similar to the flash player issue, not all versions of all web browsers will support this at present, partly due to HTML5 still being under development and not officially released as a final standard yet. You may therefore need to use a combination of solutions with some logic code in order to ensure there is a working version for at least the most used browser versions (check your website analytics to see which ones your users use).
In reality if the audio files can be played, they can be downloaded. Frustrating I know but this is just the reality. For audio the best copy protection might be to only provide a sample clip rather than the full length of the audio, or if you simply want people to come to your website you might be best to simply include an announcement at the beginning and end of the audio to introduce your website with a tagline for example.