I have an mp3 file stored in a location outside my web root. I am able to download the file using a php script, by passing a bunch of headers. However, I want to be able to directly play it, in a little audio player embedded in my website.
$file = '/location/testfile.mp3'; //this part works fine
header("Content-Transfer-Encoding: binary");
header("Content-Type: audio/mpeg");
header('Content-length: ' . filesize($file));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('X-Pad: avoid browser bug');
header('Cache-Control: no-cache');
this code is located in the tags at the top of my page, before the tag. within the body, I want to put the $file into the following code for playback:
<audio controls>
<source src="<?php echo $file; ?>" type="audio/mp3">
Your browser does not support the audio element.
</audio>
I see a player, which plays the sound. However, it covers the whole page. What am I doing wrong?