Putting a Media Code into your ASP.NET Code

Ever wanted to display a Windows Media file on your Web Page. Then here is the answer and it works for both Internet Explorer and Mozilla Firefox. First declare a variable at the top of your page for use later on. This way if you arrive to this page from another you can handle what Media file gets shown.

<script runat="server">
  Public mySrc As String = ""

  Sub Page_Load()
    mySrc = "video/Wildlife.wmv"
  End Sub
</script>

Next Place this code on your page where you wish to see the Media.

<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="player" width="640" height="480">
  <param name="url" value="<%=mySrc %>" />
  <param name="src" value="<%=mySrc %>" />
  <param name="uiMode" value="mini" />
  <param name="autostart" value="true" />
  <param name="volume" value="50" />
  <!--[if !IE]>-->
  <object type="application/x-ms-wmp" data="<%=mySrc %>" width="640" height="480">
    <param name="src" value="<%=mySrc %>" />
    <param name="uiMode" value="mini" />
    <param name="autostart" value="true" />
    <param name="volume" value="50" />
  </object>
  <!--<![endif]-->
</object>

It’s as easy as that.