Saturday, January 29, 2011

Embed a media player in a web page in ASP.Net

We can embed the media player in a web page in many ways. But the easiest and the most straight forward way is to place a literal control on the web page. Then just set the text of the same as mentioned below:



Step 1:

'---Place the Literal control on the web page as mentioned below:



< asp:literal id="ltrlMediaPlayer" runat="server">< /asp:literal>

Step 2:

'--- Set the text of the literal control as mentioned below:



ltrlMediaPlayer.Text = "< OBJECT ID='MediaPlayer' WIDTH='320' HEIGHT='240'" & _

"CLASSID='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' " & _

"STANDBY='Loading Windows Media Player components...' " & _

"TYPE='application/x-oleobject' VIEWASTEXT>" & _

"< PARAM name='FileName' VALUE='ACTUAL FILE PATH' > " & _

"< PARAM name='autostart' VALUE='false'> " & _

"< PARAM name='ShowControls' VALUE='true'> " & _

"< param name='ShowStatusBar' value='true'> " & _

"< PARAM name='ShowDisplay' VALUE='false'> " & _

"< EMBED TYPE='application/x-mplayer2' NAME='MediaPlayer'> " & _

"< /EMBED>" & _

"< /OBJECT>"


Note: 'ACTUAL FILE PATH' should be the complete path of the file to be played in the media player.

No comments:

Post a Comment

Ajax CalendarExtender displaying at wrong position in Chrome

< script type ="text/javascript" language ="javascript">     function onCalendarShown(sender, args)...