Estoy trabajando en una manera de servir a los archivos MP3 a través de PHP y después de algún tipo de ayuda del SO masiva, lo tengo trabajo hereConfiguración de Apache para servir PHP cuando se solicita un archivo MP3
Sin embargo, ese ejemplo no parece funcionar cuando lo uso como fuente de audio en una etiqueta como esta
<html>
<head>
<title>Audio Tag Experiment</title>
</head>
<body>
<audio id='audio-element' src="music/mp3.php" autoplay controls>
Your browser does not support the audio element.
</audio>
</body>
</html>
y aquí está la PHP
<?php
$track = "lilly.mp3";
if(file_exists($track))
{
header("Content-Transfer-Encoding: binary");
header("Content-Type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3");
header('Content-length: ' . filesize($track));
header('Content-Disposition: filename="lilly.mp3"');
header('X-Pad: avoid browser bug');
Header('Cache-Control: no-cache');
readfile($track);
}else{
echo "no file";
}
Así que estoy pensando (y esto puede ser ar una mala idea, dime) que podría configurar Apache para servir un archivo PHP cuando alguien solicita un .MP3.
Así que he tres preguntas
- ¿Funcionará
- buena idea/mala idea?
- ¿Qué debería hacer? ¿Poner "AddType application/x-httpd-php .mp3" int él httpd conf hacerlo?
Genius! Inline hizo el truco y he ordenado el tipo de contenido y ahora estoy enviando un 404. – gargantuan