Windows Media Player SDK banner art
PreviousNext

Embedding Windows Media Player

This topic applies to Windows Media Player version 6.4 only.

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>
PreviousNext


© 2000-2001 Microsoft Corporation. All rights reserved.