Windows Media Player Control SDK Banner Art
*Contents *Index  *Topic Contents
*Previous Topic: Creating ASX Files
*Next Topic: Using ASX Files for Seamless Stream Switching

Working with ASX Files

An Advanced Stream Redirector (ASX) file can be sent in e-mail, used as a link reference on a Web page, created dynamically by using Active Server Pages (ASP), or exist as a stand-alone file on a local drive. An ASX file, in its simplest form, is a link to a piece of media content, such as an Advanced Streaming Format (ASF) file or stream or stored audio or video file. When a user opens an ASX file, Microsoft® Windows Media™ Player is started. The Windows Media Player then opens the file or stream defined in the ASX file. Some forms of ASX files reference another ASX file, an ASP page, or a Windows Media Station (.nsc) file. An .nsc file is used to define a Windows Media Station to the Windows Media Player.

For more information about creating .nsc files, see the Windows Media Services documentation.

Note: When an ASX file is opened by the Windows Media Player, the entire file is parsed and all Uniform Resource Locators (URLs) resolved before any content is played. If referenced content includes associated graphics, all referenced graphic files are downloaded before the content is played. This prevents long pauses between pieces of content while a graphic is being downloaded, but can also cause a long delay before the first piece of content plays.

This article contains the following sections.

Adding Comments in an ASX File

You can add comments to ASX files by following Extensible Markup Language (XML) syntax. Comments begin with <!-- and end with -->. They can appear anywhere except within element content (between element open and close tags). They are not part of the document's character data and are ignored when the ASX file is parsed.

The following code is an example of a valid comment.

<ASX version = "3.0">

<!-- This is an example comment in XML syntax. This information is
     only visible when editing an .asx file. -->

    <ENTRY>
        <REF HREF = "mms://nsserver/pubpt/filename.asf" />
    </ENTRY>
</ASX>

Adding Copyright Characters to ASX Files

The characters for copyright or trademark registration symbols ( © or ® ) do not display properly with all international character sets. To display either of these symbols properly for all users, you should use the ASCII equivalents (c) or (r) inside the COPYRIGHT element, as shown in the following code.

<COPYRIGHT>Copyright (c)1998, Microsoft Corporation</COPYRIGHT>

Using Relative Links In ASX Files

Relative links are a fully supported feature of ASX metafiles. You can use relative links in ASX files much like you use them in HTML documents. The use of relative links enables you to create ASX files that are portable, meaning you can copy or move an entire directory structure to another server without updating the paths to graphic files used as logos or banners or the HREF attributes of MOREINFO elements (if they reference files on the same Web server as the stored ASX file). Relative links, in any application that supports them, work because the parts of the URL not included in the HREF attribute of an element are included in the URL sent by the application to the server when that URL is requested. This means that the protocol (such as http://), the server name, and the virtual folder in which the file containing the relative link is located are all included in the URL that is sent to the server. If the file, media, or URL you link to using a relative link do not reside on the same server as the ASX file, the relative link is not valid.

Important: This information on relative links is correct only when using a link to an ASX file that is opened in the stand-alone Windows Media Player. When you use the embedded Windows Media Player control, all links are relative to the page on which the control is hosted, unless the ASX element BASE is used to redirect the relative path.

You can use relative links in an ASX file by creating a simple ASX file in version 1.0 ASX syntax, which contains a link to another ASX file in 3.0 syntax. All metadata (such as title, author, and copyright) displayed in the Windows Media Player is read from the second ASX file. You can use links (values of HREF attributes) in the second ASX file that are relative to that ASX file (meaning the location from which the file was opened), similar to using relative links in a Web page. All relative links in the version 3.0 ASX file must be fully relative rather than drive relative, meaning that you cannot use a relative link that begins with a "\" character or drive specification. When a URL begins with a "\" character, the link is drive-relative, which causes the Windows Media Player to attempt to open the file linked to on the drive the ASX file was opened from. Because Web servers use virtual directories, the Windows Media Player tries to find the file in a subdirectory of a virtual directory. Even if the path happened to be valid, a user would not have rights to access the physical directory on that Web server.

You can use drive-relative links when using ASX files on a single computer where all files to which the ASX file links exist on a storage device in that computer.

When you use a link to another ASX file to allow for relative links, the name displayed in the Title bar of the Windows Media Player is that of the original ASX file (the one in version 1.0 syntax).

Relative links cannot be used for URLs to a streaming media server because different protocols are used for accessing streaming media content.

The following code shows a version 1.0 ASX file pointing to a version 3.0 ASX file that contains relative links.

ASF http://example.microsoft.com/metafiles/relativelink.asx

The following code is an example of a version 3.0 ASX file containing relative links.

<ASX version = "3.0">
    <BANNER HREF = "graphics/logo1.jpg">
        <MOREINFO HREF = "category1/category1.htm" />
    </BANNER>
    <ENTRY>
        <REF HREF = "mms://samples.microsoft.com/myfile.asf" />
    </ENTRY>
</ASX>

In the previous examples, the first ASX file—the file in version 1.0 syntax—can exist anywhere accessible to the user. On a Web page, the user must be able to click a link that points to this ASX file. The version 3.0 ASX file must exist in the Metafiles virtual directory on the Web server named example.microsoft.com. The file Logo1.jpg must be in a subdirectory named Graphics of the physical directory, which is defined as the Metafiles virtual directory. The Web document Category1.htm must reside in a subdirectory of the Metafiles directory named Category1.

Using ASP Pages to Dynamically Create ASX Files

You can use ASP to dynamically generate ASX files based on information provided by users. This discussion assumes that you are familiar with ASP and defining variables.

When you use ASP pages to generate ASX files, you must define a Response type variable, as well as a Response expire variable in the ASP page because of latency issues with the Windows Media Player.

All header information must be contained on the first line of the ASP page string returned to the Windows Media Player.

The following code is an example of an ASP page used to generate an ASX file.

<%Response.ContentType = "video/x-ms-asf"%><%Response.expires=0 %><ASX VERSION="3.0">
    <TITLE>Your title here</TITLE>
    <ENTRY>
        <REF HREF ="mms://samples.microsoft.com/pubpt/filename.asf" />
    </ENTRY>
</ASX>

Top of Page Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.