View Single Post
  #3  
Old 11-16-2007, 09:00 AM
Stream Recorder
 
Posts: n/a
Default

Dynamic .WAX, .ASX metafiles generated by PHP, ASP, ASP.NET, PERL,... web-script


Quote:
Originally Posted by Froglips57 View Post
I want to use a .WAX file for protocol rollover for the hundreds of Windows Media .WMA files being served, but I do not want to make hundreds of .WAX files, one for each media file. Is there a better way to do this, or maybe some way to capture the file name and send it into the wax file as a var, so one wax could process all the files being streamed?
You can use .WAX or .ASX metafiles with Windows Media .WMA audio files. Metafiles can be generated dynamically by a web-script. You can use any programming language you're familiar with, for example: PHP, ASP, ASP.NET, PERL,... web-script.

Please note that when the .WAX, or .ASX MIME types are not set up, the text contents of the metafile might be displayed in the user's browser instead of being opened in Windows Media Player.

sample: asx_output.asp ( http: //somehost/somedir/asxOutput.asp )
Code:
<%Response.ContentType = "video/x-ms-wma"%><%Response.expires=0 %>
<ASX VERSION="3.0">
    <TITLE>Your title here</TITLE>
    <ENTRY>
        <REF HREF ="mms://somehost/somedir/filename.wma" /> 
    </ENTRY>
</ASX>
sample: asxOutput.php ( http: //somehost/somedir/asxOutput.php?channel=rock )
Code:
<?
print "Content-Type: video/x-ms-asf"."\n\n";

//Use the channel variable to generate $video_url
//  $video_url = "mms://somehost/somedir/".$channel.".asf";
//
?>
<ASX VERSION="3.0">
<ENTRY>
<REF HREF="<? echo $video_url; ?>" / >
</ENTRY>
</ASX>
asxOutput.php (http: //somehost/somedir/asxOutput.php?channel=rock)
Code:
<?php 

header("Cache-control: public"); 
header("Content-Disposition: filename=playlist.asx"); 
header("Content-Type: video/x-ms-asf;"); // setting up MIME type

$channel= $_GET["channel"]; 

function GetStream 
{ 
//your function that will get the path to your stream from a database or by whatever other mean
//example: // return "mms://somehost/somedir/" .$channel.".asf"; //filter $channel variable before using to avoid vulnerabilities
} 

echo "<asx version = \"3.0\">\n"; 
echo "<TITLE>". $channel . "</TITLE>"; //make sure to filter $channel variable

echo "<ENTRY>\n"; 
echo "<REF HREF = \"". GetStream . "\" />\n"; 
echo "</ENTRY>\n"; 

echo "</asx>\n"; 

?>
Reply With Quote