<div dir="ltr"><br><br><div class="gmail_quote">2008/9/18 Gordon Henderson <span dir="ltr"><<a href="mailto:gordon%2Basterisk@drogon.net">gordon+asterisk@drogon.net</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Thu, 18 Sep 2008, Olivier wrote:<br>
<br>
> Hi,<br>
><br>
> How can I create a web page allowing people to listen (with their own PC) a<br>
> couple of .wav/a-law files stored on a Linux server ?<br>
> Chances are users would access this web page from Internet Explorer but if I<br>
> could make it available to other browsers, that would be better.<br>
><br>
> I googled a bit and couldn't find a tag such as media://myaudiofile.wav that<br>
> would fulfill this spec.<br>
<br>
</div>If the web server is running php, </blockquote><div><br>You read in my mind : it will certainly run php !<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
then this will work:<br>
<br>
<?<br>
<br>
$action = $HTTP_GET_VARS["action"] ;<br>
$file = $HTTP_GET_VARS["file"] ;<br>
$caller = $HTTP_GET_VARS["caller"] ;<br>
<br>
if (empty ($action) || empty ($file))<br>
die ("Something went wrong") ;<br>
<br>
// Open the file<br>
<br>
$fileName = "/prefix/" . $file ;<br>
$fd = @fopen ($fileName, "rb") ;<br>
<br>
if ($fd === FALSE)<br>
{ Header ("Location: " . $caller . ".php?error=1") ; die () ; }<br>
<br>
// Send the headers to the browser<br>
<br>
$len = filesize ($fileName) ;<br>
<br>
Header ("Accept-Ranges: bytes");<br>
Header ("Content-Length: $len") ;<br>
Header ("Keep-Alive: timeout=2, max=100") ;<br>
Header ("Connection: Keep-Alive") ;<br>
Header ("Content-Type: audio/x-wav") ;<br>
<br>
if ($action == "download")<br>
{<br>
Header ("Content-Disposition: attachment; filename=\"$fileName\"");<br>
Header ("Content-Description: File Transfer");<br>
}<br>
<br>
// Transmit the file in 8K blocks<br>
<br>
while (!feof ($fd) && (connection_status () == 0))<br>
{<br>
set_time_limit (0) ;<br>
print (fread ($fd, 1024*8)) ;<br>
flush () ;<br>
}<br>
<br>
fclose ($fd) ;<br>
<br>
?><br>
<br>
If this was called playback.php, then you'd reference it in other HTML<br>
code with:<br>
<br>
<a href="payback.php?action=play&file=music.wav&caller=thisFile">Click<br>
here to play</a><br>
<br>
I've found that seems to let most browsers play (or download) most audio<br>
files, (most of the time ;-)<br>
<br>
The browser will (should) do whatever it's configured to do with audio<br>
files. I use this to let people playback voicemail and call recordings.</blockquote><div><br>Is that all ?<br>You just have to specify "Content-Type: audio/x-wav" and it will work with an Internet Explorer browser ?<br>
That's good news for me.<br><br>Thanks for sharing this.<br><br>Cheers<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<font color="#888888"><br>
Gordon<br>
</font><div><div></div><div class="Wj3C7c"><br>
_______________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
<br>
AstriCon 2008 - September 22 - 25 Phoenix, Arizona<br>
Register Now: <a href="http://www.astricon.net" target="_blank">http://www.astricon.net</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br>
</div></div></blockquote></div><br></div>