I want to play from dynamic link for MP3
I am using this code to send mp3 instead of direct link :
PHP Side :
$filename = "jadi.mp3";
$mime_type = "audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3";
if (is_file($filename)) {
header("Content-Type: {$mime_type}");
header('Content-length: ' . filesize($filename));
header("Content-Disposition: attachment;filename = jadi.mp3");
header('X-Pad: avoid browser bug');
header('Cache-Control: no-cache');
header("Content-Transfer-Encoding: binary");
$fd = fopen($filename, "r");
while (!feof($fd)) {
echo fread($fd, 1024 * 200);
}
fclose($fd);
exit();
}
HMLL side :
<audio controls>
<source src="http://localhost/music.php" type="audio/mpeg" preload="auto">
Your browser does not support the audio element.
</audio>
But the Browser can not play that , I have no problem with WAV file , but for mp3 , it does not work
there is no problem if I use direct link instead of php script , so my browser can support MP3
thanks