Windows Media : Simple Embedding

Description: Goal- Embed the Windows Media Player in Microsoft Internet Explorer (IE). This sample describes how to put the Media Player directly into a Web page for IE.

More Details

The Windows Media Player installs as both a stand-alone application and as an ActiveX control. The stand-alone application allows us to play content in the Media Player as we did with our basic and advanced ASX files. Since the Media Player installs an ActiveX component as well, we're able to put the Media Player directly into a Web page, using the ActiveX architecture.

Code to Include

We'll start with our generic cross-browser code embedding code. This code will instantiate the Media Player ActiveX control for browsers which support ActiveX:

<object id="MediaPlayer1" width="160" height="112" classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase=",0,02,0902" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"> <param name="FileName" value="mms://windowsmediaserver/path/your-file.asf"></object> In the code above, we're using the tag to instantiate the ActiveX control. Each attribute of the tag provides information to the browser about how the ActiveX control behaves. Here's what each attribute does: Attribute Description ID Gives the a name within the Internet Explorer Document Object Model (DOM).

WIDTH and HEIGHT Specifies the default size of the ActiveX control. CLASSID The is the unique identifier for the Media Player ActiveX control. This ID is registered in Windows when the control is installed.

CODEBASE This attribute gives a location to auto-download the control if it is not already installed. The Version number at the end of the line specifies which version of the product is required to show the content.

STANDBY Similar to "ALT" text for an element, the STANDBY attribute is a messaging tool to let the user know that IE is installing an ActiveX control.

TYPE This specifies a MIME type for the ActiveX control.

The tag(s) provide information to the ActiveX control about how it is designed to behave. The Media Player has about 100 properties, which you can read about in some of the more advanced topics. The Media Player SDK contains detailed information about each of the Media Player's properties.

In this sample, we're only using the "FileName" property of the Media Player ActiveX control. This simply points to a piece of content via a Uniform Resource Locator (URL). The URL can point to either a Web server or to a Windows Media server. Since the Media Player control understands the mms:// protocol, we are not required to use an ASX to play ASF content. Of course, it is still preferable to use one, and will allow the Media Player control to use the advanced features of ASX.

Browser/Platform Compatibility This code will work on any browser that supports ActiveX controls (for example, Internet Explorer 3.0+ on Win32 platforms).
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.