There are many different streaming solutions that allow a file to be played as it is being downloaded. At this point, the two most popular are the Microsoft NetShow player (also known as the Windows Media Player) and the RealNetworks RealPlayer. Free players exist for both Netscape Navigator and Internet Explorer on a number of different operating systems that play NetShow, RealAudio, and RealVideo media files.
You can find more information about coding for and creating files for the RealPlayer at www.real.com. Extensive information about NetShow can be found at microsoft.com/windows/windowsmedia and on the SBN Workshop on the companion CD and the Web. On the CD, see Workshop (References); Streaming & Interactive Media; Windows Media Technologies. To get to the online version, visit the MSDN Online Resource page at msdn.microsoft.com/resources/schurmandhtml.htm, or open the file named MSDN_OL.htm on the companion CD and choose Streaming & Interactive Media.
NetShow can stream audio, video, and other types of content. It consists of an Active Streaming Format (ASF) file, which contains media, and an optional ASX file that includes instructions on how to play the ASF file and how to download from alternate servers if a primary server is busy or unavailable. You can convert existing audio and video files to ASF files with free tools available from microsoft.com/ntserver/basics/netshowservices. Available tools include command-line and graphical video and audio file converters, ASF editing tools, and plug-ins and add-ons, which allow output to ASF from both Adobe Premiere and Microsoft PowerPoint.
NOTE
NetShow and ActiveMovie represent different technologies that have merged over time. At this point, most media in Windows (including files historically handled through NetShow and ActiveMovie) is handled through the Windows Media Player, which can play most files with the following filename extensions: .avi, .asf, .asx, .rmi, .wav, .ra, .ram, .rm, .rmm, .mpg, .mpeg, .m1v, .mp2, .mpa, .mpe, .mid, .rmi, .qt, .aif, .aifc, .aiff, .mov, .au, and .snd.
One advantage of NetShow files is that they allow embedding of nonmedia elements (such as standard script code, text, and special commands) in the streamed files. This technology can be used to:
Although it is possible to embed the Windows Media Player in a page, it is more common to simply launch the video in an external window using the anchor method, described earlier in the chapter. Listing 17-5 demonstrates how to embed a NetShow stream and an anchor that launches an external player.
Code Listing 17-5.
<HTML> <HEAD> <TITLE>Listing 17-5</TITLE> <script language="JavaScript"> // This code makes Netscape Navigator better able to use the player. if ( navigator.appName == "Netscape" ){ navigator.plugins.refresh() document.write("\x3C" + "applet MAYSCRIPT Code=NPDS.npDSEvtObsProxy.class" ) document.writeln(" width=5 height=5 name=appObs\x3E \x3C/applet\x3E") } </script> </HEAD> <BODY> Embedded Media Player <BR> <!— Object tag is used by Internet Explorer —> <OBJECT ID="MPlayer" width=160 height=112 type="application/x-oleobject" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" CODEBASR="http://activex.microsoft.com/activex/controls/mplayer/en/ nsmp2inf.cab#Version=5,1,52,701" STANDBY="Loading Media Player components..."> <PARAM NAME="FileName" VALUE="keister.asx"> <PARAM NAME="AutoStart" VALUE="true"> <PARAM NAME="ShowControls" VALUE="false"> <!—Embedded plug-in for Netscape —> <EMBED TYPE="video/x-ms-asf-plugin" WIDTH="160" HEIGHT="112" PLUGINSPAGE="http://www.microsoft.com/windows/mediaplayer/download/ default.asp" FILENAME="keister.asx" SRC="keister.asx" CONTROLTYPE=0> </EMBED> </OBJECT> <P> <A HREF="keister.asx">Start the Media Player in an external window.</A> <P> <A HREF="http://www.microsoft.com/windows/mediaplayer/download/"> Get the full version of the Media Player.</A> </BODY> </HTML> |
Figure 17-6. This technique plays embedded video or starts an external window.
Listing 17-5 displays an embedded video and two links. This particular video is a sample file from the NetShow Web site and was designed for delivery over a standard 28.8 modem connection. If the user has not yet downloaded the Media Player, it will load automatically in Internet Explorer because of the CODEBASE attribute. In Netscape Navigator, if the player is not available an icon indicating that it needs to be downloaded will display. When clicked, it will prompt the user to download the player from the location specified in the PLUGINSPAGE attribute.
NOTE
There are several good reasons not to use CODEBASE to autodownload the player. First, it downloads a "light" version of the player that does not include all the codecs that come with the full version of the Media Player. This means it might not be able to play all video formats. Second, the CODEBASE that is specified downloads a version for 32-bit Windows systems (Windows 98, Windows NT, and Windows 95). This version does not work on Macintosh, Windows 3.x, or UNIX systems (although versions do exist for these systems). Thus, on all pages that use NetShow, we recommend that you include a link to the Windows Media Player downloads page, as shown in the sample. Another option is to use browser sniffing (discussed in Chapter 23) to determine what browser and operating system are being used, and only use CODEBASE when appropriate.