First, we create a page property in the code-behind page (C# file).
Now we embed the property in the HTML like this...public partial class _Default : System.Web.UI.Page
{
//name of the video we're showing.
string thisvideo = "";
//this is the read-only property. In the page it'll be seen as <%=VideoUrl %>
public string VideoUrl
{
//it only has a 'get' no set.
get
{
//only calculate this if we haven't already
if (thisvideo == "")
{
//list the *.flv files in the /flv folder
//these look like the full path... i.e. "c:\...\flv\filename.flv"
string[] videos = Directory.GetFiles(Server.MapPath(@"~/flv"), "*.flv");
//pick one based on the seconds portion of the current time.
int i = DateTime.Now.Second % videos.GetLength(0);
//strip off the path and extention
//"filename"
thisvideo = Path.GetFileNameWithoutExtension(videos[i]);
}
return thisvideo;
}
}
Ok, this seems needlessly complicated, but note the green text. This is the page property we created in the code behind page...<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300"
id="FLVPlayer">
<param name="movie" value="flv/FLVPlayer_Progressive.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="scale" value="noscale" />
<param name="salign" value="lt" />
<param name="FlashVars" value="&MM_ComponentVersion=1&skinName=flv/Clear_Skin_1&streamName=<%=VideoUrl %>&autoPlay=true&autoRewind=true" />
<param name="swfversion" value="8,0,0,0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
<param name="expressinstall" value="js/expressInstall.swf" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="flv/FLVPlayer_Progressive.swf"
width="400" height="300">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="scale" value="noscale" />
<param name="salign" value="lt" />
<param name="FlashVars" value="&MM_ComponentVersion=1&skinName=flv/Clear_Skin_1&streamName=<%=VideoUrl %>&autoPlay=true&autoRewind=true" />
<param name="swfversion" value="8,0,0,0" />
<param name="expressinstall" value="js/expressInstall.swf" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<h4>
Content on this page requires a newer version of Adobe Flash Player.</h4>
<p>
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt="Get Adobe Flash player" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
Bryan Valencia is a contributing editor and founder of Visual Studio Journey. He owns and operates Software Services, a web design and hosting company in Manteca, California.
0 comments:
Post a Comment