Captioning for Windows Media
Adding Captions to Windows Media
Article Contents
- Page 1: Introduction to Captioning for Windows Media
- Page 2: Creating a SAMI File
- Current page: Page 3: Adding Captions to Windows Media
- Page 4: Getting Windows Media Captions on the Web
Options for Combining Captions with Media
Important
There are several resources on the web that describe this process. They are nearly all WRONG. The solutions they prescribe only work in limited ways or not at all. Read on for the guaranteed way to get your captions to work with Windows Media Player.
There are two ways of adding your captions to your media file. If your media is going to play embedded within a web page, then you can create code within the web page to add your captions. However, we do not suggest embedding media because of the lack of accessibility to the Windows Media Player plugin and incompatibilities between player versions. Even if you are going to embed, it is suggested that you use an ASX file. An ASX file is a pointer file. It contains details about your media presentation and tells Windows Media Player which files to retrieve and play. The ASX file can point to your media file and your caption (SAMI) file and have them both play at the same time. For security reasons, if you are streaming media content, you should always use an ASX file. When you want someone to view your media clip from your web page, you create a link to or embed the ASX file. This ASX file is saved on your web server with your web pages. When it is opened by Windows Media Player, it instructs Windows Media Player which files to display and how to display them. The ASX file is the easiest way to add captions to your media content.
Creating an ASX File
The ASX file contains information about your content and tells WMP which files to play. The ASX file is based on XML. Newer versions of Window's Media content use the WVX (Windows Video) and WAX (Windows Audio) files. They do the same thing and are formatted the same as the ASX, but have a different file extension.
The ASX file is just a standard text file and can be created using any text editor. The ASX file is used to control what Microsoft calls a show. The show can contain one or several media clips. Let's take a look at the structure of a basic ASX file.
<asx version="3.0">
<abstract>This is the shows abstract</abstract>
<title>The show title goes here</title>
<author>Author Name</author>
<copyright>(c) 2002 - company name</copyright>
<entry>
<ref href="mediaclip.avi" />
<abstract>This is the clips abstract</abstract>
<title>The title for the clip goes here</title>
<author>Your Name</author>
<copyright>(c) 2000 - company name</copyright>
</entry>
</asx>
<asx version="3.0"> identifies to WMP that this is an ASX file and the version of the code that is being used. Each show can have a unique <abstract>, which is a description, a show <title>, <author> and <copyright> information. These go below the opening asx tag and before the first <entry> tag. Each <entry> represents one media clip that will play in sequence for the show. This show only contains one clip. If you wanted to play multiple media clips in succession, just add additional <entry> tags.
The ref href value will be equal to the location of the media clip you want to play. This can be simply the file's name if it is in the same location as the ASX file. You can also enter the value as http://server.com/path/filename.ext to open a file located on another Web server. If you are streaming from a Windows Media Server, this will probably be mms://mediaserver.com/path/filename.ext. Each entry can also have an abstract, title, author, and copyright. You can see below where the show information is displayed when the previous ASX file is opened in WMP 6.4. The box is opened using .
The section is the <abstract>. It can be much longer in length than the other sections. Each clip's details can be seen in the information section below the or by selecting the tab from the . Because each show can contain multiple clips, the clip information changes based on which clip is currently playing.
In WMP version 7+, the show information does not display. The clip information does display for each clip and some of the information is available through menu.
The top of the player above (WMP for Windows XP) shows the author and the clip title. The section of the player that currently displays Song:... will cycle through the clip's title, copyright, and author information. The abstract is not displayed anywhere.
Adding Caption Information to Your ASX File
Note
In the following examples, the code should be on one continuous line. Do not enter a line break or space after the question mark. It is done here so that you don't have to scroll horizontally.
The only guaranteed way to get a caption file (SAMI) to be associated with your media file is to add the following <ref> tag to your ASX file:
<ref href="http://www.webserver.com/mediafile.ext?SAMI=http://webserver.com/samifile.smi"
Notice the placement of the quotation marks. Most resources on the web
incorrectly position the quotation marks that surround the href
value. Misplacing the quotation marks may work for older media players,
but will not work with WMP
7+. Be sure to enter absolute references (http://...)
for both the media file and the SAMI
file. This is the ONLY way to reliably get captions to display in all versions
of WMP. Remember that Windows
Media Player will open the ASX file from your web server, then look
for the files the ASX file references.
If the media file is in a different location than the ASX file, the reference may look like this:
<ref href="http://www.webserver.com/movies/movie.asf?
SAMI=http://www.anotherserver.com/samifile.smi">
If you are streaming video from a Windows Media Server, the ONLY way to get captions to properly appear in the standalone media player is to format the reference like this:
<ref href="mms://www.windowsmediaserver.com/movie.wmv?
SAMI=http://www.webserver.com/samifile.smi">
See also:
- There are plenty of other cool things you can do with ASX files. You can add banner images for audio only broadcasts, you can add interactivity, and set viewing duration. Learn more at the Microsoft Web site - external link.