This is one of the basic requirements of a site; you may want to play a media file or a play list (group of media files). Here are few simple steps to create a web page with media player on it.
1. Open Visual Studio 2005\2008
2. File -> New ->Website, Give this site a name, like MySite
3. Create a new folder under your site, Right Click on site -> New Folder, name it Videos.
4. Copy all the media files you want to play on site.
5. Create a playlist, Right click on Videos folder -> Add New Item -> Text File -> Name it Playlist.m3u
6. Open the Playlist.m3u file and provide list of files with relative location in this, each file in new line. I.e. -
/MySite/Videos/Evian.wmv
/MySite/Videos/Too_Good.mpeg
7. Now, open the Default.aspx page, and add following code in <div> or <table> as per you site layout:
<object id="MediaPlayer1" width="360" height="400" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft® Windows® Media Player components..." type="application/x-oleobject"
style="text-align: center;">
<param name="FileName" value="Videos/Playlist.m3u" />
<param name="loop" value="True" />
<param name="ShowStatusBar" value="True" />
<param name="DefaultFrame" value="mainFrame" />
<param name="autostart" value="true" />
</object>
8. Save the file and Run this site. It will play the playlist provided.
Note- if you want to play just a single file in Media Player, just replace the line
<param name="FileName" value="Videos/Playlist.m3u" />
With line
<param name="src" value="Videos/Too_Good.mpeg" />
Happy Coding!!!
No comments:
Post a Comment