Embedding Windows Media Player
 
Embedding Windows Media Player

Windows Media Player SDK banner art

To accommodate cross-browser compatibility, you can enable 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 code segment.

<OBJECT ID="MediaPlayer" WIDTH=320 HEIGHT=240 
    CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
    STANDBY="Loading Windows Media Player components..." 
    TYPE="application/x-oleobject">

  <PARAM NAME="FileName" VALUE="demo.asf">
  <EMBED TYPE="application/x-mplayer2" 
    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 a Windows Media 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>


© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View