Embedding JW FLV Media Player in ASP.Net forms

Recent days I got a project with requirement to play flv video, so I found an free for non commecrial purposes flv player, but the problem that I had was how to find way to "control" what the player is going to play by the users' choise. So what I needed was to "inject" this javascript embedded player dynamically into pages' html, that way I got the power to control what is going to be passed to and played by the player (I've used url query string to pass videos' file name to the player as parameter). So here how I did it:

What I did in aspx file was to put holder for the javascript player code:

<asp:PlaceHolder ID="PlaceHolder1" runat="server" />

Then I used HtmlGenericControl to "inject" the javascript player code into holder:

Dim Span As New HtmlControls.HtmlGenericControl("span")

   Span.Attributes.Add("style", "z-index: 80")
   Span.InnerHtml = "<a id=""container"" href=""
http://www.macromedia.com/go/getflashplayer""></a>" & _
   "<script type=""text/javascript"" src=""swfobject.js""></script>" & _
   "<script type=""text/javascript"">" & _
   "var s = new SWFObject(""mediaplayer.swf"",""mediaplayer"",""" & "400" & """,""" & "300" & """,""" & "8" & """);" & _
   "s.addParam(""allowfullscreen"",""true"");" & _
   "s.addVariable(""width"",""" & "400" & """);" & _
   "s.addVariable(""height"",""" & "300" & """);" & _
   "s.addVariable(""file"",""" & "" & Request.QueryString("filename") & ".flv" & """);" & _
   "s.addVariable(""image"",""" & "" & """);" & _
   "s.addParam(""wmode"", ""transparent"");" & _
   "s.write(""container"");" & _
   "</script>"

   PlaceHolder1.Controls.Add(Span)

4 Comments

Comments have been disabled for this content.