Click Here to Install Silverlight*
United StatesChange|All Microsoft Sites
Windows Media Player 9 Series
|Windows Media Worldwide

Using the Windows Media Player 9 Series HTMLView Feature

Kevin Larkin and Jim Travis
Microsoft New Media Platforms Division
January 2003

Applies to:
Microsoft® Windows Media® Player 9 Series

Contents

Introduction

The Microsoft® Windows Media® Player 9 Series HTMLView feature enables Internet content providers (ICPs) to use the
Abstract
Windows Media Player 9 Series includes a new feature, called HTMLView. Learn how to use HTMLView, how to create HTMLView content, and how to resolve potential issues you may encounter when using the HTMLView feature.

(13 printed pages)
Now Playing feature of the Player to display Web-based content while digital media content is playing. In the past, ICPs had to display advertisements in separate Web browser windows (called "pop-up advertising") or had to add customized digital media players to their Web pages. With HTMLView, ICPs can provide a personalized and integrated experience created specifically for Windows Media Player 9 Series, while ensuring that digital media content still plays back in earlier versions of Windows Media Player.

This article provides information about using HTMLView, creating HTMLView content, and resolving potential issues you may encounter when using the HTMLView feature.

Back to the top of this pageBack to the top


Advantages of Using HTMLView

The Windows Media Player 9 Series HTMLView feature makes it easy to create an integrated Web-based user experience that plays back digital media content by using the familiar look of the Web. When you combine Web-based content with digital media content in the Windows Media Player user interface (UI), the result can have a greater impact on the user than when the elements are viewed separately. The digital media content is enhanced by interesting, related information, while the Web page can provide links to similar content, thereby creating new selling opportunities.

The following image uses the HTMLView feature to display Web-based content that combines digital video content with links to similar content and purchasing opportunities.

Figure 1. Example of HTMLView in Windows Media Player 9 Series
Figure 1. Example of HTMLView in Windows Media Player 9 Series

HTMLView Provides a Better User Experience
Users want and enjoy accessing the information that can be offered with digital media content, but they don't want to deal with a seemingly endless series of pop-up advertisements. Using pop-up browser windows to display advertising on the Web has become so commonplace that there is now software that prevents these windows from opening. This software can have the unwanted side effect of preventing legitimate Web pages from being displayed, sometimes suppressing an entire digital media presentation.

When you use the HTMLView feature, users no longer have to deal with pop-up windows. Instead of having to open a separate browser window to provide additional information to the user, you can display custom, Web-based content in the Now Playing feature of the Windows Media Player UI while the Player plays the audio or video content the user wants. Users can control playback by using the Windows Media Player controls. Since your content plays in the full-mode Player, software designed to prevent pop-up ads won't stop users from enjoying the content.

HTMLView Content is Easy to Create
As the feature name implies, you create Web-based content displayed using the Windows Media Player 9 Series HTMLView feature by using Hypertext Markup Language (HTML). If you already create content for the Web, this means that you don't need to learn a new programming language to create rich content easily with the HTMLView feature. If you already have Web pages with an embedded Windows Media Player ActiveX® control, you can have these pages appear in the Player UI by simply pointing to these Web pages from a Windows Media metafile (.asx file) by using a special parameter.

Windows Media Player 9 Series uses an embedded instance of Microsoft Internet Explorer to display HTMLView content. This means that you don't have to consider different Internet browsers, multiple scripting models, or different scripting languages when creating your Web pages. Even if the user doesn't use Internet Explorer as his or her default browser, your Web page is still displayed properly in the Player.

It is possible that a program other than Windows Media Player may register itself as the default program for opening .asx files. The Windows Media Player 9 Series object model includes a new method, openPlayer, which enables you to specify a Uniform Resource Locator (URL) for the content you want to play. When you use the openPlayer method, Windows Media Player 9 Series always opens in full mode to play the specified content. Using this method, you can ensure that your HTMLView content is displayed in Windows Media Player, rather than some other application that has taken over the .asx file type association.

Back to the top of this pageBack to the top


Creating an HTMLView Presentation

To create a basic HTMLView presentation, you need at least three elements:

  • Digital media content. This is one or more audio or video files that Windows Media Player plays.
  • A Web page. This is the Web-based content that displays in the Now Playing feature of the Player UI.
  • A Windows Media metafile. This is the metafile playlist that directs Windows Media Player to combine the digital media content with the Web page.

An .asx file is a text file that provides information about a file stream and its presentation. Based on Extensible Markup Language (XML) syntax, .asx files can contain a variety of elements, each identified by a tag with associated attributes. The PARAM element provides a way to associate a custom parameter with either a particular entry in a metafile playlist or the entire metafile. One of the predefined parameter names available for your use is "HTMLView". This is the parameter that causes the Web page specified by the URL value to be displayed in Windows Media Player.

The following example code shows an .asx file that combines a single digital media file with a single Web page:

<ASX version="3.0">
<PARAM name="HTMLView" value="http://www.proseware.com/htmlview.htm"/>

<ENTRY>
   <REF href="rtsp://www.proseware.com/content1.wma"/>
</ENTRY>

</ASX>
When Windows Media Player 9 Series opens the .asx file in the preceding example, it plays the audio from the file named "content1.wma" and opens the Web page named "htmlview.htm" in the Now Playing feature of the full-mode Player. The user can pause, seek, and stop the audio content using the Windows Media Player controls.

You can easily change the Web page that is displayed for each piece of content by associating a PARAM element with each entry, as the following code example shows:

<ASX version="3.0">

<ENTRY>
   <PARAM name="HTMLView" 
    value="http://www.proseware.com/htmlview1.htm"/>
   <REF href="rtsp://www.proseware.com/content1.wma"/>
</ENTRY>

<ENTRY>
   <PARAM name="HTMLView" 
    value="http://www.proseware.com/htmlview2.htm"/>
   <REF href="rtsp://www.proseware.com/content2.wma"/>
</ENTRY>

</ASX>
In the preceding example, Windows Media Player 9 Series first displays the Web page "htmlview1.htm" while playing the digital audio file "content1.wma." When the Player opens the next entry in the playlist, "content2.wma," the Web page displayed in Now Playing changes to "htmlview2.htm." In this way, you can specify which Web page the user sees for each piece of digital media content.

Adding an Embedded Windows Media Player Control
There are two reasons you might consider adding an embedded instance of Windows Media Player to your HTMLView presentation. First, if you want to display video content, you need to use the Windows Media Player ActiveX control. Second, if you want to take advantage of features of the Player object model from within your HTMLView Web page, you must use an instance the Player control to do so.

Using the Player control to display video in HTMLView content
Usually, Windows Media Player displays video using the Video and Visualization pane of the Now Playing feature. Since HTMLView uses this area to display your Web page, you must supply an additional video display area if you want the Player to play video. This is easy to do by using the Windows Media Player ActiveX control.

To use the Player control to display video, embed the control in your HTMLView Web page by using the OBJECT tag. This is the same technique you use to embed the Player control into any Web page in which you want to display video. The following example code shows the basic syntax for embedding the Player control in Internet Explorer:

<OBJECT id = "Player"
    CLASSID = "CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
        <PARAM Name = "autoStart"  Value = "true">
        <PARAM Name = "uiMode" Value = "none">

</OBJECT>
The autoStart parameter ensures that content plays automatically whenever a new URL is specified. The value you specify for uiMode is up to you, but you will usually want to specify "none" when creating content for HTMLView presentations. When you embed the Player control to display video in this manner, the user can control playback using the controls of the full-mode Player, so there's no need to provide additional transport controls in the Web page. You can use the space you would usually allocate for transport controls to display more text, graphics, or links to other content.

Do not specify a URL parameter when embedding the Player control in a Web page designed to display in an HTMLView presentation. Instead, specify the digital media files in the .asx file that opens the content.

Because you provide the video display region in your HTMLView Web page, you can decide where to position the video and how large you want the display region to be. For example, you can contain the Player object within an HTML DIV element and then specify the position for the DIV to situate the video display on the Web page. You can change the dimensions of the video display by specifying values for the height and width attributes of the OBJECT element. You can also specify these values using script code.

Using the Player object model
The Windows Media Player 9 Series object model exposes properties, methods and events that you can use in your HTMLView Web pages. When you embed the Windows Media Player 9 Series ActiveX control in your HTMLView Web page, you automatically have access to the Player object model. For more information about the Windows Media Player 9 Series object model, including samples that demonstrate various uses of the embedded Player control, you can download and install the Windows Media Player 9 Series Software Development Kit (SDK).

If you embed the Player control in your HTMLView Web page, do not use the Player object model to specify the digital media file to be played. For example, if you use script code to specify a value for the URL property of the embedded control, your HTMLView Web page will be unloaded from the Now Playing feature when the digital media file plays. To prevent this from happening, always open .asx files that include HTMLView parameters when you need to use script to open digital media content from your HTMLView Web page.

Ensuring that Windows Media Player 9 Series Opens the HTMLView Content
Currently, Windows Media Player 9 Series is the only player that supports the HTMLView parameter in .asx files. This means you should take steps to ensure that your HTMLView content plays back in Windows Media Player 9 Series. To do this, you must first check to determine whether Windows Media Player 9 Series is installed on the user's computer. The Windows Media Player 9 Series SDK includes a comprehensive sample that demonstrates how to detect different versions of Windows Media Player in different Web browsers. Although a complete analysis of the detection sample is beyond the scope of this article, there are some basic steps you can take to determine which version of the Player the user's computer is running.

In its simplest form, detecting Windows Media Player 9 Series involves embedding the Player control in the Web page that links to your HTMLView content and then inspecting the value retrieved by the Player.versionInfo property. Once you have verified that the user has Windows Media Player 9 Series installed, you can use the Player.openPlayer method to open the content in the full-mode Player. The openPlayer method ensures that your content is initially displayed in the Now Playing feature of the full-mode Player, rather than in a skin, in mini Player mode, or in another player that has registered itself as the default program for files with an .asx file name extension, but doesn't support HTMLView. Once the content is displayed, however, the user has complete control of Windows Media Player, meaning that he or she can choose to display a feature other than Now Playing, switch to skin mode or even quit the Player.

The following example code creates a Web page for Internet Explorer that opens an .asx file that specifies an HTMLView Web page that appears in the full-mode Player when Windows Media Player 9 Series is installed.

<HTML>
<BODY>

<!-- This code embeds the Player object in invisible mode. -->
<OBJECT id = "Player" 
    CLASSID = "CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" height = 0 
      width = 0> 
        <PARAM Name = "AutoStart"  Value = "True">
        <PARAM Name = "uiMode" Value = "invisible">
</OBJECT>

<!-- Create a button to open the content. -->
<INPUT Type = "Button"  ID = "btnPlay"  Value = "Play ASX"  onClick = 
  "PlayASX();"/>

<SCRIPT Language = "JScript">

// This function tests the Player version. If it is Windows Media 
// Player 9 Series, the script opens the .asx file in the full-mode 
// Player. Otherwise, the script makes the embedded control visible to 
// the user and opens the .asx file in the Web page. 

function PlayASX()
{
    if(parseInt(Player.versionInfo) >= 9)
        {
            // Open the full-mode Player to show HTMLView.
            Player.openPlayer("http://www.proseware.com/MyHTMLView.asx");
        }
        else
        {
            // Open the .asx file in the embedded Player.
            Player.uiMode = "full";
            Player.height = 200;
            Player.width = 200;
            Player.URL = "http://www.proseware.com/MyHTMLView.asx";
        }
}
</SCRIPT>

</BODY>
</HTML>
The code in the preceding example embeds the Player control with the uiMode property set to "invisible" and the Player height and width attributes set to zero. This is because the Web page does not require the Player control user interface to be displayed initially—it only requires access to the Player object model. The page also displays an input button that enables the user to play the .asx file.

When the user clicks the Play ASX button, the Microsoft JScript® function named PlayASX() runs. This function first retrieves the value for the Player versionInfo property, using the JScript parseInt method to inspect the numerical value of the string retrieved. If the numerical value is greater than or equal to 9 (meaning that the user has Windows Media Player 9 Series installed on his or her computer), the script code calls the openPlayer method, passing the URL of the .asx file that contains the HTMLView parameter. This method opens the .asx file using Windows Media Player in full mode, plays the digital media content in the .asx playlist, and displays the HTMLView Web-based content in the Now Playing feature.

If the numerical value of the version string is not greater than or equal to 9 (meaning that the user does not have Windows Media Player 9 Series installed on his or her computer), the script code changes the uiMode of the Player control to "full", sets a new width and height for the control, and then opens the .asx file in the embedded Player by specifying a value for the URL property. When this happens, the digital media content plays in the Web page, but any HTMLView values specified in the .asx file are ignored.

How content is played back when the user does not have Windows Media Player 9 Series installed is up to you. The preceding example shows how to specify that the content play in the Web page instead of the full-mode Player, ignoring any HTMLView content in the process. There are other approaches you might take. For example, you could prompt the user to install Windows Media Player 9 Series, making that version of the Player a requirement for playing back your digital media content.

Back to the top of this pageBack to the top


Web Page Issues

There are some things to consider when you create a Web page to be displayed in the Windows Media Player Now Playing feature. This section discusses some of the issues you might encounter when creating your Web-based content.

Customizing HTMLView
Your HTMLView Web page can be as simple or complex as you want. You can include any of the elements you usually use in your Web-based content. If you embed the Player control, you can display one of the user interfaces supplied by the control, create your own user interface using HTML and script code, or provide no UI at all (which means that the user can use the transport controls of the full-mode Player).

The recommended size for Web pages displayed by using the HTMLView feature is 575 x 345 pixels. The user, however, has the ability to resize the Player and choose the screen resolution. If the HTMLView Web page is larger than the size accommodated by the Now Playing feature, the Player displays horizontal and vertical scroll bars that enable the user to see the entire page. You should test your HTMLView content using a variety of screen resolutions and Player sizes to determine the best size for your Web page.

Windows Media Player does not provide a method that enables you to specify a size for the full-mode Player.

Web page navigation
Windows Media Player does not provide a navigation toolbar for Web pages displayed in the Now Playing feature. This means that you have complete control over whether users can navigate away from your HTMLView Web page. If you want to enable users to navigate to other Web pages, you must include elements in your HTML code to provide that functionality.

Retrieving the parent window
If your existing script code uses window.parent to retrieve the parent window object, this code will not work in your HTMLView Web page. When you use HTMLView, there is no parent window object; therefore, this scripting feature is unavailable.

About the embedded browser
Because Windows Media Player uses an embedded instance of Internet Explorer to display HTMLView content, the user settings and policies for Internet Explorer apply to any Web pages displayed in the Player. For example, if the user has configured Internet Explorer to prevent Web pages from downloading cookies to the computer, your HTMLView Web page is also prevented from doing this.

Web pages opened using the HTMLView feature always run in the Internet Explorer Internet security zone.

The embedded Web browser control uses the same rules to cache Web pages as the stand-alone version of Internet Explorer. It's a good idea to use Active Server Pages (ASP) when creating your content to ensure that the content is delivered from your Web server each time the Player accesses the HTMLView Web page. Using ASP pages can be as simple as renaming your Web page to use an .asp file name extension.

About local Web content
The HTMLView feature does not allow you to open Web pages that are stored on the user's computer.

Prompting the user
You can use window.prompt to prompt the user for information. However, window.alert and window.confirm are not available when using HTMLView.

Timing issues
You may encounter timing issues when using an embedded Player control in your HTMLView Web page. In HTMLView, an embedded Player control shares its playback engine with the stand-alone Windows Media Player. It is possible that the stand-alone Player may open and begin playing the first playlist entry before the Web page (and, therefore, the Player control) finishes loading. This means that if you handle the OpenStateChange or PlayStateChange events, the script code will not receive event notifications for these events until the Player control and its associated objects are loaded.

You can take steps in your code to delay playback until the Player control is instantiated. One way to do this is to make the first entry in your metafile playlist point to an image file and set the duration of the file to a length of time that allows the Player control to load. The following example code demonstrates this option:

<ASX version="3.0">
   <PARAM name="HTMLView" 
     value="http://www.proseware.com/htmlview1.htm"/>

<ENTRY>
   <REF href="http://www.proseware.com/blank.jpg"/>
   <DURATION  VALUE = "1:00"/>
</ENTRY>

<ENTRY>
   <REF href="rtsp://www.proseware.com/content1.wma"/>
</ENTRY>

</ASX>
When the preceding playlist opens, the Player waits at the first entry in the playlist for up to one minute while the Player loads the HTMLView Web page.

Next, in your HTMLView Web page, write script code to handle the onload event for the BODY element. In the event handler function, call the Player Controls.Next method to begin playback of the second entry in the playlist.

<HTML>
<!-- Define the event handler function. -->
<BODY  onload = "OnLoad();">

<OBJECT id = "Player" 
    CLASSID = "CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"> 
        <PARAM Name = "autoStart"  Value = "true">
        <PARAM Name = "uiMode" Value = "none">

</OBJECT>

<!-- Handle the BODY onload event. -->
<SCRIPT>
function OnLoad()
{
   // Advance to the second entry in the playlist.
   Player.controls.next();
}
</SCRIPT>

</BODY>
</HTML>
When the Web page in the preceding example finishes loading, the Player immediately advances to the second entry in the playlist. This overrides the duration specified for the first element in the playlist, meaning that the user doesn't have to wait the full one minute before seeing the desired content; he or she only has to wait for the Web page to finish loading. Because the Player control is completely instantiated at this point, the OpenStateChange and PlayStateChange events can be handled in the usual manner.

Back to the top of this pageBack to the top


Controlling the Playback Experience

This section discusses some of the playback issues you may encounter when using the HTMLView feature.

Requiring the User to View the Web-based Content
You may decide that you only want users to be able to enjoy your digital media content when the HTMLView Web-based content is also displayed. You can include script code in your HTMLView Web page that stops playback of the digital media content if the user switches away from the Now Playing feature. To do this, you can specify an event handler for the unload event as part of the BODY element, as the following HTML code demonstrates:

<BODY onunload = "UnloadMe();">
Then you can include script code in your event handler function to close the file in the Player. The following example code does this:

function UnloadMe()
{
   Player.close();
}
When the user switches away from Now Playing by clicking a button to open another Windows Media Player feature, such as Media Library, the Player closes the embedded browser. This causes the onunload event to occur, running the script in the function named UnloadMe. The Player.close method stops playback and unloads the current digital media file. In order to view the content again, the user must reopen the original .asx file. This technique also stops playback when the user navigates away from the HTMLView Web page. Note that this technique cannot prevent the user from viewing the digital media content when he or she switches to skin mode.

You will recall that the HTMLView parameter can be applied to each ENTRY element in an .asx file. You can take advantage of this feature to ensure that your HTMLView content is displayed each time a new digital media file starts. To do this, associate a PARAM element for HTMLView with each entry in your .asx playlist. When each entry plays, the Player returns to full mode and displays the HTMLView content you specified in the playlist.

URL and FILE script command types are disabled by default
Windows Media Player 9 Series provides settings that enable the user to specify whether URL and FILE type script commands are able to run. By default, both of these script command types do not run. If you use custom script command types, they will continue to run, regardless of the user setting. If you must use URL and FILE type script commands, you must prompt the user to change the settings. To change the settings, click Tools, then Options and then Security.

Reopening an HTMLView does not reload the Web page
When the user opens an .asx file that includes an HTMLView parameter and subsequently reopens the same file, Windows Media Player does not refresh the HTMLView Web page. This also means that if you have allowed users to navigate away from your HTMLView Web page, the Player does not return the embedded browser to the initial HTMLView Web page.

Hiding the content location
You might decide that you don't want Windows Media Player to display the location of your digital media content while it is playing an .asx file. Usually, Windows Media Player only shows information about the playlist itself when streaming content from the Internet. However, there are further steps you can take to prevent users from determining the location of your content. For example, one way to ensure that the Player does not display the path to your content is to stream your content using Windows Media Services 9 Series server-side playlists. That way, when the user views the properties for the content, he or she sees the URL of the server and not the URL of your content.

Back to the top of this pageBack to the top


Compatibility Issues

Netscape Support
Web pages opened by the HTMLView feature are displayed using an embedded instance of Microsoft Internet Explorer. No Netscape compatibility is required for HTMLView content. If you need to embed an instance of Windows Media Player 9 Series in the Web page that links to the HTMLView .asx file, you must use the Player Java applet if the page needs to support Netscape browsers. For more information about using the Java applet, see the Windows Media Player 9 Series SDK.

No HTMLView Support in Earlier Versions of Windows Media Player
Currently, Windows Media Player 9 Series is the only version of Windows Media Player that supports the HTMLView feature. Earlier versions of the Player and versions created for other platforms ignore the HTMLView parameter when parsing an .asx file. When this happens, the digital media content plays as expected, but the Web-based content is not displayed in the Now Playing feature.

Back to the top of this pageBack to the top


For More Information

To learn more about Windows Media Player 9 Series, see Windows Media Player 9 Series Help. Windows Media Player 9 Series can be downloaded from the Windows Media page.

To learn more about the Windows Media Player 9 Series ActiveX control, see the Windows Media Player 9 Series SDK.

Also, see Windows Media Player 9 Series SDK documentation.

Back to the top of this page Back to the top



© 2016 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy & Cookies
Microsoft