|
When providing streaming video and/or audio content to your web site visitors, you may find it desirable to embed the visitor's Windows Media Player into your web page so the user sees your content as a seamless part of your site, versus a popup Windows Media Player launched by clicking on a link. Here's a simple example of embedding the player: <OBJECT ID="mediaPlayer" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" Height="320" Width="240"> <PARAM name="autoStart" value="True"> <PARAM name="URL" value="mymedia.wmv"> <EMBED type='application/x-mplayer2' pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='0' bgcolor='darkblue' showcontrols='0' showtracker='1' showdisplay='0' showstatusbar='0' videoborder3d='0' width="320" height="240" src="mymedia.wmv" autostart='1' designtimesp='5311' loop='0'> </EMBED> </OBJECT> In this case, the embedded player is used to display a 320 X 240 video. The autoStart parameter causes the media to begin playing automatically, and the URL parameter specifies the path to the media file. It can be a relative path as above, in which case the player will look for a file in the same directory as the web page, or it can be the full url to a media file at another location, such as a streaming media server. Within the <OBJECT> section of the code is an <EMBED> section, which will allow the embedded media to play in a Mozilla based browser (Firefox or Netscape), or a browser with ActiveX disabled. There are additional options you can use to tailor the embedded player to your needs. For specifics, please see the followng Microsoft knowledge base article: Using the Windows Media Player Control in a Web Page Creating a player page Once you have the hang of embedding audio and video into a web page, you may want to take it a step further by creating a single embedded player page that can play all of your media. To do this in ASP on Windows, create a page named player.asp, and put your embedded player in it as specified above, with one exception: make the URL parameter look something like this: <PARAM name="URL" value="<%=Request.QueryString("mediafile")%>"> Then, whenever you want to play a media file, from anywhere on your site, link to your player.asp page with this syntax: <A HREF="player.asp?mediafile=mymedia.wma">Play My Song!</a> The player.asp page will replace <%=Request.QueryString("mediafile")%> with the mediafile variable you specify in the link, and the embedded media player will play the file. If your media files are on a separate media server, you'll want to hardcode the media server name in the URL parameter, like this: <PARAM name="URL" value="http://mediaservername/<%=Request.QueryString("mediafile")%>"> That way you won't have to put the server name into all your links, just the name of the media files. For PHP the process is identical, except your player page will be named player.php, and the url parameter will look like this: <PARAM name="URL" value="http://mediaservername/<?php echo $_REQUEST["mediafile"] ?>">
|