<div dir="ltr"><br><br><div class="gmail_quote">2008/9/18 Gordon Henderson <span dir="ltr">&lt;<a href="mailto:gordon%2Basterisk@drogon.net">gordon+asterisk@drogon.net</a>&gt;</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>
&gt; Hi,<br>
&gt;<br>
&gt; How can I create a web page allowing people to listen (with their own PC) a<br>
&gt; couple of .wav/a-law files stored on a Linux server ?<br>
&gt; Chances are users would access this web page from Internet Explorer but if I<br>
&gt; could make it available to other browsers, that would be better.<br>
&gt;<br>
&gt; I googled a bit and couldn&#39;t find a tag such as media://myaudiofile.wav that<br>
&gt; 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>
&lt;?<br>
<br>
 &nbsp; $action = $HTTP_GET_VARS[&quot;action&quot;] ;<br>
 &nbsp; $file &nbsp; = $HTTP_GET_VARS[&quot;file&quot;] ;<br>
 &nbsp; $caller = $HTTP_GET_VARS[&quot;caller&quot;] ;<br>
<br>
 &nbsp; if (empty ($action) || empty ($file))<br>
 &nbsp; &nbsp; die (&quot;Something went wrong&quot;) &nbsp;;<br>
<br>
// Open the file<br>
<br>
 &nbsp; $fileName = &quot;/prefix/&quot; . $file ;<br>
 &nbsp; $fd &nbsp; &nbsp; &nbsp; = @fopen ($fileName, &quot;rb&quot;) ;<br>
<br>
 &nbsp; if ($fd === FALSE)<br>
 &nbsp; &nbsp; { Header (&quot;Location: &quot; . $caller . &quot;.php?error=1&quot;) ; die () ; }<br>
<br>
// Send the headers to the browser<br>
<br>
 &nbsp; $len = filesize ($fileName) ;<br>
<br>
 &nbsp; Header (&quot;Accept-Ranges: bytes&quot;);<br>
 &nbsp; Header (&quot;Content-Length: $len&quot;) ;<br>
 &nbsp; Header (&quot;Keep-Alive: timeout=2, max=100&quot;) ;<br>
 &nbsp; Header (&quot;Connection: Keep-Alive&quot;) ;<br>
 &nbsp; Header (&quot;Content-Type: audio/x-wav&quot;) ;<br>
<br>
 &nbsp; if ($action == &quot;download&quot;)<br>
 &nbsp; {<br>
 &nbsp; &nbsp; Header (&quot;Content-Disposition: attachment; filename=\&quot;$fileName\&quot;&quot;);<br>
 &nbsp; &nbsp; Header (&quot;Content-Description: File Transfer&quot;);<br>
 &nbsp; }<br>
<br>
// Transmit the file in 8K blocks<br>
<br>
 &nbsp; while (!feof ($fd) &amp;&amp; (connection_status () == 0))<br>
 &nbsp; {<br>
 &nbsp; &nbsp; set_time_limit (0) ;<br>
 &nbsp; &nbsp; print (fread ($fd, 1024*8)) ;<br>
 &nbsp; &nbsp; flush () ;<br>
 &nbsp; }<br>
<br>
 &nbsp; fclose ($fd) ;<br>
<br>
?&gt;<br>
<br>
If this was called playback.php, then you&#39;d reference it in other HTML<br>
code with:<br>
<br>
 &nbsp; &lt;a href=&quot;payback.php?action=play&amp;file=music.wav&amp;caller=thisFile&quot;&gt;Click<br>
 &nbsp; &nbsp; &nbsp; &nbsp;here to play&lt;/a&gt;<br>
<br>
I&#39;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&#39;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 &quot;Content-Type: audio/x-wav&quot; and it will work with an Internet Explorer browser ?<br>
That&#39;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>
 &nbsp; <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>