Description Goal: To use the TEXT event in an ASF file to add captioning support for both Microsoft Internet Explorer and Netscape Navigator. ASF has the ability to send script command events to the browser. The TEXT script command event will add HTML markup directly into the Media Player's captioning window. By doing this, you can quickly and easily add accessibility support, as well as include additional, time-based data within the ASF file. More Details TEXT script command events are intrinsically handled by the Windows Media Player, like URL script command events. Instead of grabbing a new document, the TEXT script command event replaces the HTML markup in the captioning window with new text. Code to Include This file will use our generic cross-browser code embedding code. This code will instantiate the Media Player ActiveX control for browsers which support ActiveX, and the Media Player plug-in for browsers that don't:

<object id="MediaPlayer1" width="160" height="182" classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase=",1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"> <param name="FileName" value="http://webserver/path/your-file.asx"> <param name="ShowStatusBar" value="True"> <param name="ShowCaptioning" value="True"> <param name="ShowPositionControls" value="True"> <embed type="application/x-mplayer2" pluginspage="" src="http://webserver/path/your-file.asx" name="MediaPlayer1" width="160" height="182" showstatusbar="-1" showpositioncontrols="0" showcaptioning="-1"></embed></object> We'll even link to the file in an external player for downlevel browsers. <a href="javascript:document.mediaplayer1.stop();location.href='demo.asx';">Open External Player</a> The above code may not work properly with Netscape Naviagor. Use the following code instead with Netscape. <a href="/article/windows-development/demo.asx">Open External Player</a> This code stops the Media player (two media players playing at once can be quite distracting), and then opens the ASX file, which spawns the Media Player stand-alone application. And here is the ASX syntax: <asx version="3.0"><title>External Captioning Demo</title> <entry><title>Captioning Demo</title> <author>Your Author Info</author><copyright>Your Copyright info</copyright><ref href="mms://windowsmediaserver/path/your-file.asf"></ref></entry></asx> Since the Text event is handled instrinsically by the player, we won't need any JavaScript for this sample. We will, however, need to embed the script commands inside the ASF file. We can do this using the ASF Indexer tool (a part of the Windows Media tools package). First, open up the ASF Indexer -- the default location of this tool is Start->Programs->Windows Media->ASF Indexer. Once it is running, select File->Open. This will bring up a dialog box which will allow you to specify a piece of ASF content. Click the "Edit Script Commands" button. This will bring up the "Script Commands" dialog box. Click "New." Choose a time for your script command (in hours:minutes:seconds.tenths format) and specify the "Type" of script command as "TEXT." The parameter field is where you can put your HTML markup. Note that for each 1/10 second interval, there is a maximum of approximately 230 characters. If your markup is longer than that, it will be truncated to fit in the available space. Your ASF Indexer should look something like this: Repeat this process for all of your TEXT events, click "OK," and then File->Save. Now you have created TEXT script commands in your ASF file. Browser/Platform Compatibility This code will work with Internet Explorer 4+, and Netscape Navigator 4+ on platforms that support the Windows Media Player plug-in and ActiveX control.

Complete Article

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.