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)

Published Tuesday, January 27, 2009 12:19 PM by stoian bucovich

Comments

# re: Embedding JW FLV Media Player in ASP.Net forms

Thursday, February 19, 2009 5:55 PM by Ricardo

Hi, do you know how is it possible to invoke commands directly on the player?

I tried to embedd javascript functions, but i can't call them.

# re: Embedding JW FLV Media Player in ASP.Net forms

Friday, February 20, 2009 11:52 AM by stoian bucovich

What you are trying to achive? Provide an example please.

Thanks,

Stoian Bucovich

# re: Embedding JW FLV Media Player in ASP.Net forms

Monday, April 06, 2009 5:11 AM by nick_qoepunk

hmm that example is not work

# re: Embedding JW FLV Media Player in ASP.Net forms

Sunday, April 12, 2009 7:10 AM by stoian bucovich

Hi,

Sure it's working, you can find it up and running on the following address: www.ilievart.net/Video.aspx

This is one of the places where I have used it.

Best regards,

Stoian Bucovich

SNB Web Solutions

www.snb-bg.com

# Stoian bucovich | Alliterationpl

Saturday, November 26, 2011 3:50 PM by Stoian bucovich | Alliterationpl

Pingback from  Stoian bucovich | Alliterationpl

Leave a Comment

(required) 
(required) 
(optional)
(required)