Contents Index Topic Contents | |
Previous Topic: Using the Windows Media Player Plug-in Next Topic: Invoking Methods |
Embedding Windows Media Player
To accommodate cross-browser compatibility, you can enable the Microsoft® Windows Media™ Player in a Web page so that it can be successfully downloaded to either Microsoft® Internet Explorer or Netscape Navigator. For Netscape Navigator, use the EMBED tag to embed a plug-in. For Internet Explorer, use the OBJECT tag to embed the Microsoft® ActiveX® control. To ensure that Windows Media Player is enabled properly for both types of browsers, you can nest the EMBED tags within the OBJECT tags, as illustrated in the following sample code segment.
<OBJECT ID="MediaPlayer" WIDTH=320 HEIGHT=240 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" CODEBASE="http://activex.microsoft.com/activex/ controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" STANDBY="Loading Microsoft® Windows Media™ Player components..." TYPE="application/x-oleobject"> <PARAM NAME="FileName" VALUE="demo.asf"> <EMBED TYPE="application/x-mplayer2" PLUGINSPAGE="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&" SRC="C:\Program Files\Windows Media Components\SDK\Samples\Plugin\demo.asf" NAME="MediaPlayer" WIDTH=320 HEIGHT=240> </EMBED> </OBJECT>In this example, Windows Media Player is configured to play the demo.asf file in the C:\Program Files\Windows Media Components\SDK\Samples\Plugin directory. The Windows Media Player control is identified as MediaPlayer, which is specified by the ID attribute of the OBJECT tag. The plug-in is also named MediaPlayer, which is specified by the NAME attribute of the EMBED tag. You can use the object identifier MediaPlayer, in the script to refer to the Windows Media Player when invoking methods, accessing properties, and handling events.
The preceding code example uses branded MIME types to load Windows Media Player to play an .asf file. This use of branded MIME types ensures automatic version upgrade for the plug-in on a user machine. All other supported media types can be specified in a similar fashion. The following code snippet loads and, if necessary, upgrades the plug-in, and plays a WAV file, an AVI file, and an MP3 file.
<EMBED TYPE="application/x-mplayer2" SRC="myWAV.wav"></EMBED> <EMBED TYPE="application/x-mplayer2" SRC="myAVI.avi"></EMBED> <EMBED TYPE="application/x-mplayer2" SRC="myMP3.mp3"></EMBED>
Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.