Embedding the Player in a Web Page


Embedding Windows Media Player in a Web page can be beneficial for several reasons. It enables you to make use of corporate branding, control the size of the Player so you can be sure that it integrates with your site design, and control the amount of interactivity users have with the Player. For example, you can decide whether to include the rewind, fast forward, and pause buttons.

Both Internet Explorer and Netscape Navigator support embedding the Windows Media Player ActiveX control. However, the method for embedding the control is unique for each browser. Netscape Navigator does not directly support embedding of ActiveX controls, so the Player install program includes a Java applet that will host the Player ActiveX control when it is used with Navigator version 4.7 and later.

Unless you know for sure what browsers your viewers will be using when they visit your site, you’ll probably want to add some code to your Web page that will detect the browser being used and then choose the appropriate embedding technique. You don’t have to worry about confusing the browser with extra code because browsers only pay attention to the code they understand. If, for example, a customer connects to your site with Internet Explorer, the browser will execute the code that Internet Explorer understands and will ignore the code intended for Netscape browsers. The reverse is true as well.

Users of either browser must install Windows Media Player before viewing pages that embed the control. If Windows Media Player is installed after Netscape Navigator, the Player applet and an accompanying dynamic link library (DLL) are added to the appropriate Netscape directories automatically. In this case, no further setup is required by your users in order to view your pages in Navigator. You should instruct users who have installed Windows Media Player before Navigator to run the Player installation program again after Navigator has been installed.

Using the Player Control with Internet Explorer

To embed the Player control in a Web page for use with Internet Explorer, you use the OBJECT element with the ID and CLASSID attributes. You can use the HEIGHT and WIDTH attributes to specify the dimensions of the Player. Here is an example of the code used to embed the Player in a page that is viewed by Internet Explorer:

<OBJECT ID=’Player’ height=’200' width=’200'      CLASSID=’CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'></OBJECT>

Internet Explorer uses the PARAM element to define specific startup conditions for the control. The PARAM element is embedded within the OBJECT element, and has two attributes: NAME and VALUE. Both attributes must be set. Here is an example of how the PARAM element is used:

{{     document.writeln("<OBJECT ID=’WMPEmbed’ height=’240' width=’320'         CLASSID=’CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'>");     document.writeln("<PARAM NAME=’autoStart’ VALUE=’FALSE’/>");

The following table describes some common name attributes that can be used with the PARAM element. For a full description of all of the available attributes, see the Windows Media Player SDK.

Parameter Name

Value

Description

autoStart

True or False.

Specifies whether the media item begins playing automatically Default is “true.”

UIMode

Invisible, none, mini, full, or custom.

Specifies which controls are shown in the user interface. Default is full, meaning all controls are displayed.

URL

Any fully qualified URL.

Specifies the name and location of the clip.

Using the Player Control with Netscape Navigator

To embed the Player control in a Web page so that it displays correctly in
Netscape Navigator, use the APPLET element with NAME and CODE attributes. You can use the HEIGHT and WIDTH attributes to specify the dimensions of the Player. Here is an example of the code used to embed the Player control for Netscape Navigator:

<APPLET NAME="Player" CODE="WMPNS.WMP" HEIGHT="200" WIDTH="200"> </APPLET>

To enable your Web pages to be viewed by both browsers, use the following SCRIPT element in the BODY element of your page at the location where the Player is to appear:

<SCRIPT> if (navigator.appName == "Netscape")  {     document.writeln("<APPLET NAME=’Player’ HEIGHT=’200'          WIDTH=’200' CODE=’WMPNS.WMP’>");     document.writeln("<PARAM NAME=’URL’ VALUE=’video.wmv’/>");     document.writeln("</APPLET>"); }  else  {     document.writeln("<OBJECT ID=’Player’’HEIGHT=’200' WIDTH=’200'          CLASSID=’CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'>");     document.writeln("<PARAM NAME=’URL’ VALUE=’video.wmv’/>");     document.writeln("</OBJECT>"); } </SCRIPT>

Note

All the Player control functionality available in Internet Explorer is also available in Navigator except for the defaultFrame property. In Navigator, each URL-type script command received displays the URL in a new browser window, regardless of the value of defaultFrame.




Microsoft Windows Media Resource Kit
Microsoft Windows Media Resource Kit (Pro-Resource Kit)
ISBN: 0735618070
EAN: 2147483647
Year: 2005
Pages: 258

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net