Search the site:
EXPERT SEARCH

| Programming Languages
| Databases
| Security
| Web Services
| Network Services
| Middleware
| Components
| Operating Systems
| User Interfaces
| Groupware & Collaboration
| Content Management
| Productivity Applications
| Hardware
| Fun & Games

EarthWeb sites
Crossnodes
Datamation
Developer.com
DICE
EarthWeb.com
EarthWeb Direct
ERP Hub
Gamelan
GoCertify.com
HTMLGoodies
Intranet Journal
IT Knowledge
IT Library
JavaGoodies
JARS
JavaScripts.com
open source IT
RoadCoders
Y2K Info

- 10 — Using the ActiveMovie Control

- Dynamic Programming
- Streams and Plumbing

- ActiveMovie Stream Editor

- Creating an ActiveMovie Stream

- Adding Content
- Coordinating Content
- Testing and Building the Movie

- ActiveMovie on the Web

- Embedding ActiveMovie on a Page
- Controlling ActiveMovie with VBScript
- Properties
- Methods
- Events

- What's Next

#
10 — Using the ActiveMovie Control

by John J. Kottler

Throughout this book, you have learned about Microsoft's ActiveX technology and seen how it can be used to move Web pages from their current, static state to a new interactive plateau. However, creating Web pages with fancier interfaces is only part of making the Web interactive. Although users can now do something on ActiveX-enabled Web pages, they still want to see, hear, and feel results. To date, one of the most powerful media tools available is video. With video, you have the opportunity to see and hear things never before imaginable. Just as a picture paints a thousand words, sometimes audio and video animation paint a million.

Yet anyone who has browsed the Internet through a standard dial-up connection with a modem knows that such capabilities are beyond their reach. Current technology allows you to view video or audio information, but only after you have completely downloaded the source material to your personal computer. Depending on the content and your connection rate, this can take anywhere from a minute to 30 minutes or more.

In an attempt to make video and audio look instantaneous, and therefore become more of a reality for Web pages, Microsoft has introduced a new ActiveX component: ActiveMovie. Within Internet Explorer 2.x and 3.x, it's already possible to embed Video for Window files or MIDI (Musical Instrument Digital Interface) sound files on a page. When Internet Explorer views these pages, these files are immediately downloaded and displayed within the context of a Web page, like inline graphics. However, only simple video files can be embedded, ones that aren't very long and don't require a vast amount of time to download. The ActiveMovie control allows you to embed video within a Web page, yet offers a higher degree of control and supports many additional technologies. ActiveMovie can be found at Microsoft's Web site: www.microsoft.com.

####
Dynamic Programming

Video for Windows has been the long-established standard for playing video content on Windows-based machines. Although it's quite suitable to use Video for Windows and its underlying Media Control Interface (MCI) today, newer video technologies and user expectations are placing higher demands on the development environment. Although Video for Windows is included with newer operating systems, such as Windows 95, ActiveMovie will soon become its replacement for many reasons:

- ActiveMovie is just what its name implies: active. It is possible to control attributes of the video content dynamically while it is playing. For example, you can adjust the video's brightness or contrast while the video is playing.
- It is CODEC (COmpressor/DECompressor) independent. This means that ActiveMovie controls work with digital video of any format. With ActiveMovie, you can control MPEG, QuickTime, or Video for Windows video files.
- ActiveMovie is an ActiveX control, so it's object-oriented. In the past, controlling Video for Windows through the Media Control Interface required knowledge of the MCI commands. As an ActiveX control, it's much easier for developers to create applications that interact with video content because it shields you from the complexities of multimedia.
- Instead of being required to transfer an entire video file, it's possible to transmit just the beginning and have the computer begin playing it. While that portion is playing, additional data is transferred in the background to be played. This "streaming" technology is supported by ActiveX and will make using and controlling video files over low-bandwidth connections, such as modem access to the Internet, feasible. In addition, streaming content uses the same control interface in ActiveMovie that's used for standard video.

As you can see, ActiveMovie gives great value to developers. A sample application created later in this chapter demonstrates how to use the ActiveMovie ActiveX control within a Web page to display both video content and streaming video content.

####
Streams and Plumbing

ActiveMovie makes use of streaming technology to make video content seem to download faster than it really does. The technique of streaming data is fairly simple. When a user chooses to view video content on a Web page, the video viewer is invoked. The data for the video file then starts to download from the Internet to the local PC. An important difference is that not all the data needs to be transferred for the streaming video viewer to start. Instead, only a few seconds' worth of video is downloaded to begin the playback of the video. While that video is playing, additional video data is passed from the Internet to the local PC in the background. The end result is a video that seems to begin playing almost instantly.

Another benefit of streaming video is that the video content can be much longer, or even infinite in length. For instance, with streaming video technology, it's possible to connect to a live video feed, such as a television or cable channel, at a site. Programming for that channel can be continuous, and the stream continues to read data from the Internet as long as it's instructed, since the data is constantly fed to the video viewer on a user's PC. However, as you know from browsing the Internet and experiencing delays, this continuous stream of data can lose its continuity. Most streaming technologies provide for this situation and either appropriately notify the user or simply "skip" until the actual data is transferred.

It's also important to notice that since data is streamed into a video viewer, less disk space is required locally on a user's computer for storing digital video. Because only a few seconds of video are necessary to start playback, a small buffer is created on a local hard disk. Old information in that buffer is cleared out, and new content is replaced as the video stream plays.

The quality of the video played back on a user's machine is directly related to the speed at which that person is connected to the Internet. You can think of the connection between a local PC and the Internet as a pipe. A pipe can handle only so much water passing through it at a time. If you try forcing more water through a pipe than what it can handle, water spills out over the ends of the pipe or the pipe bursts. In the case of the Internet, if more data is streamed to a local computer than what that computer's connection can handle, the data "spills", causing gaps and pauses in content, such as video.

Video requires a large amount of information, which in turn translates to a vast amount of water to push through a pipe. Typical video content will easily "spill" when a user is connected to the Internet by a traditional 28.8K bps modem. The only solution to avoiding spills is to increase the size of a pipe. Technologies such as ISDN and cable modems offer larger pipes for denser data like video to flow more freely.

Until these larger pipes are laid through the Internet's plumbing, however, newer technologies can adjust their content based on the size of the "pipe" between a computer and the Internet. One example of this is Microsoft's ActiveMovie Streaming Format (.ASF) files. Using an Editor like ActiveMovie Stream Editor, a developer can create content that can be streamed and displayed accurately by using restricted "pipes".

###
ActiveMovie Stream Editor

Creating content that can be viewed using low-bandwidth connections is certainly a challenge. It's difficult to determine how much information can be passed at once over such a connection. Determining how to display the content using the least amount of the bandwidth is where the problem lies. A 28.8K bps connection to the Internet translates as a pipe that allows information to flow through at a rate of 3600 bytes per second. In a world where small and compressed pictures are easily twice that size, full-motion video through such a pipe is difficult.

However, Microsoft's ActiveMovie Stream Editor software helps you to develop content that uses audio and an animated slide show. The trade-off is a quick connection for media content, but low-quality audio and still pictures displayed in a sequence. Not exactly as compelling as full-motion video, but almost as useful.

####
Creating an ActiveMovie Stream

Once you have installed the ActiveMovie Stream Editor on your computer, you can begin to create streaming content for the ActiveMovie control. Figure 10.1 is an example of the ActiveMovie Stream Editor window with content already added to the workspace.

Figure 10.1. The ActiveMovie Stream Editor makes creating streaming content for the Internet easier.

You will quickly notice that the workspace is divided into two regions: a timeline in the top half of the screen and a list of files for the project at the bottom of the screen. When you first start the ActiveMovie Stream Editor, you see a blank workspace. You must first choose the objects you want to present in the movie, then place them accordingly on the timeline.

#####
Adding Content

Remember, the ActiveMovie Stream file is simply a series of still pictures presented in an orderly fashion. However, you can also add an underlying soundtrack or voice track. In either case, the audio and picture files must be added to the ActiveMovie Stream project you're creating. This ActiveMovie Stream project is then be used to create an ActiveMovie Stream File (.ASF), one of many file types supported by the ActiveMovie control.

To add a picture or audio file to the project, choose Add Files from the File menu or click the Add Files button on the Editor's toolbar; this opens a dialog box that prompts you to choose the audio (.WAV) or picture (.JPG/.BMP) files to add to the project. The objects you select are then added to the list at the bottom of the Editor window.

When adding digital audio content to your ActiveMovie Stream project, you must add files that are compressed using one of the digital audio compressors installed on your system. If you're using Windows 95 or Windows NT 4.0, these compression algorithms are included with the operating system. To convert a digital audio file (.WAV) to one of these compressed formats, you can simply use the Sound Recorder application included with Windows 95.

After you've opened the file you want to convert into the Sound Recorder, then save it using the Save As command from the File menu. When the dialog box opens asking you to specify the name of the new sound file, click the Change button at the bottom of the window to change that file's format. This opens a window, shown in Figure 10.2, where you can select a new format to use when saving the audio information.

Figure 10.2. Audio files must be saved in a compressed format, such as ADPCM, to be used in the ActiveMovie Stream Editor.

TIP
The Microsoft ADPCM compressor for audio files works well with the ActiveMovie Stream Editor. When converting sound files using the Sound Recorder application, it doesn't matter what you choose for the file's compression attributes. When the audio file is imported into the ActiveMovie Stream Editor, it's converted into a format suitable for playback at the bit rate you're using for the movie.

Pictures stored in either Windows Bitmap (.BMP) or JPEG (.JPG) formats may be added to the file. To convert pictures to these formats, use a program such as Paint Shop Pro, which is included on this book's CD-ROM. With Paint Shop Pro, you can open a source graphic, then save it again as either a Windows Bitmap or JPEG picture.

TIP
When converting pictures to use in the ActiveMovie Stream Editor, consider changing some of the picture's qualities to reduce its final size. One method for reducing an image's size is to save it as a JPEG file. JPEG is a compression scheme that dramatically reduces the size of certain images. You might also consider creating smaller pictures that use fewer pixels both in width and height because they load faster and, therefore, work better in an ActiveMovie Stream.
Another method for reducing a picture's size is to reduce the amount of colors it uses. Avoid using pictures that are full-color images (24-bit), or convert them to 256 color, or even lower color depths, to get smaller file sizes.

#####
Coordinating Content

Once you have added the pictures and sound files you want to use in the ActiveMovie Stream Editor project, you can begin coordinating the sound and graphics for your presentation. This requires scheduling each picture or sound to occur at specific points in time by using the timeline window near the top of the Editor's screen.

To schedule a picture or sound file for a specific point in time, you can simply drag the source file you want to add from the list of files at the bottom of the Editor window onto the timeline. Once you have dragged the file onto the timeline, it's represented by a colored rectangle on the timeline—pictures are green; sounds are blue. In the example in Figure 10.1, a soundtrack, represented by a long rectangular bar, occupies the long bottom half of the timeline. Likewise, the pictures for the presentation are represented by the smaller rectangles just above the sound clip's rectangle.

Note that the timeline directly relates not only to the length of the final presentation, but also to the amount of information squeezed through the pipe at one time. For instance, the sound clip in this example is a little over twenty-six seconds in length, so the rectangle representing that sound in the ActiveMovie Stream file is wide enough to occupy twenty-six seconds on the timeline. Notice also that the height of this sound clip's rectangle is about half the height of the overall timeline window. The height of the timeline window represents the total bandwidth available for content. In this example, the ActiveMovie Stream file is created to run with a bit rate of 28.8K bps. Therefore, the height of the timeline indicates the size of the pipe and how much information can be moved at one time. At a 28.8K bps connection, roughly 3600 bytes can be moved per second of connect time. In this example, the audio file was compressed to use roughly 1800 bytes per second, or half the full bandwidth for the pipe.

The audio file plays constantly throughout the entire presentation, so half the pipe must be dedicated to playing the audio stream for the movie. As a result, the remaining portion of the pipe handles the pictures. In the example shown in Figure 10.1, you will notice that most of the pictures are displayed for longer than a second, according to the timeline, because the file size of these pictures is larger than the remaining size of the pipe. For example, a picture with a file size of 3600 bytes can't possibly be transferred in a single second, if only 1800 bytes are available per second in the pipe. Therefore, that image will automatically require at least two seconds to transfer; this can't be changed unless the bit rate is altered to accommodate a higher or lower bandwidth.

Pictures are displayed in the order in which they appear on the timeline. However, since some pictures need a predetermined amount of time to be transferred and displayed, it's hard to be creative when coordinating pictures with sound. You might find that to get the effect you want, you have to make much smaller pictures than you originally wanted.

Another method of reducing the amount of information passed through the pipe is to convert the files between compression formats. Often, if you drag a file from the project list at the bottom of the window onto the timeline and it requires more bandwidth than the ActiveMovie Stream can handle, the Editor will automatically prompt you to convert formats. You can also change the format used to compress data in the movie by clicking on the picture or sound file in the timeline and then selecting Convert from the Edit menu. Figures 10.3 and 10.4 illustrate the windows used for converting audio clips and pictures, respectively.

Figure 10.3. The ActiveMovie Stream Editor software allows you to convert audio clips to use other compression formats.

Figure 10.4. Just as you can compress audio, you can also choose to compress pictures displayed in the ActiveMovie Stream Editor.

TIP
Coordinating the pictures with your sound is difficult by viewing the timeline. If you want a picture to appear on a particular "hit" in the music, such as a cymbal crash, there is no way to determine where this crash is by using the timeline. Instead, you might want to try the Editor's Tap & Snap feature; it plays an audio clip and automatically advances through the pictures added to your project. However, it only advances the pictures when you tap on the "marker" button at the bottom of the window. The Editor stores the times at which you click this button and tries to synchronize the pictures with the audio in the timeline window, based on the taps you made.

#####
Testing and Building the Movie

After you have arranged the sound and picture files on your timeline, you can then test the final output of the movie by choosing Test from the Editor's Stream menu. This "test" mode will simulate the speed at which pictures are displayed as if you were connected to the movie using the bit rate you specify. For instance, if you're creating a 28.8K bps movie, the "test" mode displays the pictures at the speed in which they would appear if you had connected and streamed this movie using a modem.

Once you're satisfied with the movie's presentation, you can build the final ActiveMovie Stream File (.ASF). Before actually creating the file, you should first verify its properties. To do this, select Properties from the Editor's File menu. In the window that opens, you can set general information, such as the author who created the file, and more detailed information, like the bit rate for displaying the file. Figure 10.5 shows this Properties dialog box.

Figure 10.5. You can set several properties for the ActiveMovie Stream before you build the final file.

After all the properties have been verified, you can create the ActiveMovie Stream File by choosing Build or Build All from the Stream menu. This final file (.ASF), as you will see shortly, can then be played by using the ActiveMovie ActiveX control in the context of a Web page.

###
ActiveMovie on the Web

Now that you have a familiarity with what ActiveMovie is and how to create ActiveMovie Stream files, you could include videos in your own Web pages. Since ActiveMovie is an ActiveX control, it can easily be embedded in a Web page and controlled through VBScript. This section explains how to embed an ActiveMovie control, discusses its properties, methods, and events for other programming languages, such as Visual Basic, Visual C++, and VBScript, to use, and reviews a complete example of a Web page with an ActiveMovie control and VBScript.

####
Embedding ActiveMovie on a Page

Since the ActiveMovie control is simply an ActiveX control, it can be embedded on a Web page just as any other ActiveX control can. For more information on embedding ActiveX controls in Web pages, you might want to refer to Chapter 9, "ActiveX Controls and Visual Basic Script."

To insert an ActiveMovie control, you must use the <OBJECT> tag within your HTML document for a Web page. Within that tag lies the class identifier, which indicates that the ActiveMovie ActiveX control is to be loaded. Again, as with other ActiveX controls, the class ID for the ActiveMovie control exists in your system registry. By running the Registry Editor (regedit.exe) included with Windows 95, you may find the ActiveMovie control under the following directory entry:

    My Computer\HKEY_CLASSES_ROOT\AMOVIE.ActiveMovieCtrl\CLSID

The class ID for ActiveMovie may then be used in the <OBJECT> tag to create the control within the Web page. Listing 10.1 demonstrates how to embed an ActiveMovie control using the <OBJECT> tag.

Listing 10.1. The <OBJECT> tag is used to embed an ActiveMovie control on a Web page.

    <OBJECT

        classid="clsid:{05589FA1-C356-11CE-BF01-00AA0055595A}"

        id=VideoWindow

        width=320

        height=340

        hspace=20

        vspace=0

    >

    <param name="filename" value="example\jay'288.asf">

    <param name="ShowControls" value="false">

    <param name="Balance" value="0">

    </OBJECT>

As you can see in Listing 10.1, several parameters may be altered when the object is displayed initially on the Web page. These parameters are essentially the properties for the ActiveMovie control, and they can be easily set when the object is first loaded and easily changed through VBScript, as explained in the following section.

####
Controlling ActiveMovie with VBScript

Once the ActiveMovie control has been added to a Web page and given an appropriate ID to use within VBScript, that control can be easily modified or monitored through code created in VBScript for the Web page. Figure 10.6 illustrates a sample Web page containing an ActiveMovie control. In this example, there is an ActiveMovie window that displays the movie during playback, as well as three buttons to play the video, play an ActiveMovie stream, or stop the video playback altogether. In addition to these buttons, there are two sliders that control the volume and stereo balance of the audio track. These two sliders are created using VBScript and illustrate some of the dynamism of the ActiveMovie control.

Listing 10.2 is a complete listing of the HTML for this Web page, including the <OBJECT> definitions for the ActiveMovie and slider controls, as well as the VBScript needed to handle the events of sliding the sliders or clicking the buttons. You can see from the source code that several properties are set for the ActiveMovie control, as well as methods for running or stopping the media's playback.

Figure 10.6. ActiveMovie controls can be embedded on a Web page to create a more dynamic site.

Listing 10.2. The Web page in Figure 10.6 requires several <OBJECT> definitions as well as VBScript routines.

    <!--  ActiveMovie Example  -->

    <HTML>

    <TITLE>

    ActiveMovie Example

    </TITLE>

    <BODY>

    <OBJECT

        classid="clsid:{05589FA1-C356-11CE-BF01-00AA0055595A}"

        id=VideoWindow

        width=320

        height=340

        hspace=20

        vspace=0

    >

    <param name="filename" value="skiing.asf">

    <param name="ShowControls" value="false">

    <param name="Balance" value="0">

    </OBJECT>

    <P>

    <P>

    <SCRIPT LANGUAGE="VBS">

    sub SetVolume(TheVolume)

        VideoWindow.Volume=(TheVolume-9)*250

    end sub

    sub SetBalance(TheBalance)

        VideoWindow.Balance=(TheBalance-1)*10000

    end sub

    sub BalanceControl_Click()

        Call SetBalance(BalanceControl.Value)

    end sub

    sub VolumeControl_Click()

        Call SetVolume(VolumeControl.Value)

    end sub

    sub PlayAVIContent()

        BalanceControl.enabled=true

        VolumeControl.enabled=true

        VideoWindow.filename="skiing.avi"

        VideoWindow.run

        Call SetBalance(BalanceControl.Value)

        Call SetVolume(VolumeControl.Value)

    end sub

    sub StopVideoWindow()

        VideoWindow.stop

    end sub

    sub PlayASFContent()

        BalanceControl.enabled=false

        VolumeControl.enabled=false

        VideoWindow.filename="skiing.asf"

        VideoWindow.run

    end sub

    </SCRIPT>

    <FORM Name="MyForm">

    <INPUT TYPE="BUTTON"

           VALUE="Play AVI Video"

           NAME="PlayAVI"

           onClick="PlayAVIContent"

    >

    <INPUT TYPE="BUTTON"

           VALUE="Play ActiveMovie Stream"

           NAME="PlayASF"

           onClick="PlayASFContent"

    >

    <INPUT TYPE="BUTTON"

           VALUE="STOP"

           NAME="StopIt"

           onClick="StopVideoWindow"

    >

    </FORM>

    <P>Stereo Balance:<BR>

    <OBJECT

        classid="clsid:{373FF7F0-EB8B-11CD-8820-08002B2F4F5A}"

        id=BalanceControl

        width=320

        height=25

        hspace=20

        vspace=0

    >

    <!-- Set the range for the slider from 0-2 (3 values total)

       3 values are used for: left, center and right -->

    <param name="Max" value=2>

    <param name="Value" value=1>

    <param name="LargeChange" value=1>

    <param name="Enabled" value="false">

    </OBJECT>

    <P>

    <P>Volume:<BR>

    <OBJECT

        classid="clsid:{373FF7F0-EB8B-11CD-8820-08002B2F4F5A}"

        id=VolumeControl

        width=320

        height=25

        hspace=20

        vspace=0

    >

    <!-- Set the range for the slider from 0-9 (10 values total) -->

    <param name="Max" value=9>

    <param name="Value" value=5>

    <param name="LargeChange" value=2>

    <param name="Enabled" value="false">

    </OBJECT>

    </BODY>

    </HTML>

NOTE
In Listing 10.2, there are many instances where the slider controls for changing volume or stereo balance have been disabled and then enabled. In this example, the ActiveMovie video file allows you to dynamically change of these properties. ActiveMovie Stream, on the other hand, does not. Therefore, to avoid any confusion and potential runtime errors, the sliders are disabled when their respective properties aren't supported. You should try to catch or avoid all errors when possible on your own Web pages.

Since the ActiveMovie control is an ActiveX control, it features properties, methods, and events just as other ActiveX controls do. Through these object-oriented techniques, a VBScript routine can interact with the ActiveMovie control.

####
Properties

Several properties are associated with an ActiveMovie control. The following list briefly describes each property and its function; they can all be either set or read by a VBScript routine.

AllowChangeDisplayMode If you want someone viewing the video to have the ability to change the display mode, set this property to TRUE. There are two modes available: by time or by frame. The ability to change the display mode is located on a context menu, as shown in Figure 10.7.

Figure 10.7. The ActiveMovie control supports a context menu, available by right-clicking within the control.

AllowHideControls Similar to AllowChangeDisplayMode, you can determine whether you want the user to have the ability to hide or display the VCR-like buttons at the bottom of the ActiveMovie window. Hiding or displaying the controls can be done by using a context menu like that shown in Figure 10.7.

AllowHideDisplay This property determines whether the user playing a video file can display or hide the time display at the bottom of the ActiveMovie window. The display may be toggled on or off by using a menu choice in the context menu shown in Figure 10.7.

Author Holds the name of the author for the video clip.

AutoRewind If you want a video clip to automatically rewind to the starting position after it has finished playing, you can set this property to TRUE.

AutoStart Once the ActiveMovie window has been displayed, the movie can automatically begin playing when this property is set to TRUE. Otherwise, you must start the video manually.

Balance The stereo balance from left to right of the audio track for an ActiveMovie video can be adjusted dynamically. Values for this property range from -10000 (far left) to 10000 (far right). A value of 0 indicates a balanced center.

Copyright If the video clip contains copyright information, it can be extracted by using this property.

CurrentPosition This property indicates the current position of the playback in the video stream, which depends on the mode currently used (frames or time). When this property is set with a new position, the ActiveMovie player moves to that position in the video stream.

CurrentState This property can only be read by VBScript. It indicates the current status of the video content. The player's state may change when a routine in VBScript issues an appropriate command or when the user clicks the VCR buttons at the bottom of the ActiveMovie window. The status returned by this property may be any of the following:

0 The video is stopped

1 The video is paused

2 The video is playing

Description A brief description or comment can be attached to the multimedia content.

DisplayBackColor The VCR-like output for the display of the ActiveMovie window may be altered to use different colors. This property sets the background color to use for that display. Color values can be any RGB color between 0 and 16,777,215.

TIP
To help with the selection of colors, the Web Helper application has been included on this book's CD-ROM. This application has color-conversion capability as well as a translator between degrees and radians (which is useful for the Virtual Reality Modeling Language).

DisplayForeColor Similar to the DisplayBackColor property, you can set the color to use when painting the numbers and text displayed in the VCR-like output window of the ActiveMovie control.

DisplayMode The position of the content being played may be displayed in measurements of time or frames; this property is used to change the mode. The following values are used with this property:

0 Use time for measuring position

1 Use frames for measuring position

Duration The overall length of the media content can be determined by reading this property. The value returned indicates the length of the content in seconds.

EnableContextMenu When a user right-clicks on the ActiveMovie control, a pop-up menu appears containing options a user can set for media playback. Setting this property to TRUE allows the user to right-click on the ActiveMovie window and display this menu. This menu is similar to the one shown in Figure 10.7.

EnablePositionControls With this property, you can determine whether users have the ability to change the current position of the video's playback. If this property is set to TRUE, then a user can "seek" to different positions in the media file; if this property is FALSE, the respective buttons are disabled in the ActiveMovie window.

EnableSelectionControls You can establish starting and ending points for the media loaded in the ActiveMovie control. The content between these points is then referred to as the "selection". Additional selection buttons may be enabled or disabled in the ActiveMovie control to determine whether users can create selection ranges for playback. If this property is set to TRUE, then these additional buttons will be enabled. A value of FALSE will disable these buttons.

EnableTracker Near the playback controls at the bottom of the ActiveMovie window, you may find a slider control referred to as a "tracker". This control can be enabled or disabled by setting this property to TRUE or FALSE, respectively.

EventNotification There are several events associated with the ActiveMovie control. You can choose which of these events you want to trap in your application with this property. Each event is identified by a value. To trap multiple events, you may add those values together and set this property to the resulting value. For example, if you want to trap both keyboard and mouse clicks, you would use the value of 8+16, or 24. The following list describes valid events and their values:

eventNone | 0 | No events are triggered.
eventStateChange | 1 | Events are triggered when the state of the content changes; for example, stopping the current playback.
eventPositionChange | 2 | When the position updates, an event is triggered.
eventTimer | 4 | An event can be triggered each time a timer event occurs.
eventKeyboard | 8 | Pressing a key on the keyboard triggers this event.
eventMouseClick | 16 | When a mouse button is clicked, this event is triggered
eventMouseMove | 32 | As the mouse is moved, this event is triggered

FileName The filename of the media content to be displayed must be supplied for playback to begin. This property contains the name of the file to load and display in the ActiveMovie window. Filenames are either video files (.AVI) or ActiveMovie Stream Files (.ASF).

FilterGraph In addition to being able to change volume and stereo balance dynamically, you can set or change other video playback attributes, such as brightness, contrast, or other special effects. These effects are established in a filter graph. If a filter graph has been designed, you may specify using it with this property.

FilterGraphDispatch To use ActiveMovie filter graphs, you must provide a IDispatch object pointer. If you're using filter graphs, you specify this object pointer with this property.

ImageSourceHeight Video content is created using varying resolutions for pixel height and width. This property contains the control's recorded height in pixels. This is not necessarily the same size as it is when the content is played.

ImageSourceWidth Like ImageSourceHeight, it's possible to determine the original width for the content displayed in the ActiveMovie control.

MovieWindowSetting As previously mentioned, you can play video content using a different height and width for the window than what it was when originally recorded. This property allows you to set the method by which the video playback will be scaled. The following are valid values for this property:

movieDefaultSize | 0 | Uses the size at which the video was recorded.
movieHalfSize | 1 | Displays the content as half the original recorded size.
movieDoubleSize | 2 | Displays the content as twice the original recorded size.
movieMaximizeSize | 3 | Displays the content using the full size of its parent's window.
movieFullScreen | 4 | Displays the content using the full screen.
moviePermitResizeWithAspect | 5 | Allows the user to control playback size, but maintains the typical 4:3 aspect ratio.
moviePermitResizeNoRestrict | 6 | Allows the user to control playback size, ignoring aspect ratio.

PlayCount The multimedia content in an ActiveMovie control can be played repeatedly. This property establishes the number of times the content will repeat. A value of 0 for this property indicates that the content should repeat indefinitely.

Rate The media content in an ActiveMovie window can be played faster or slower than it was originally intended by adjusting this property. A value of 1.0 indicates that playback should occur at the original recorded rate. Values higher than 1.0 indicate faster playback; values lower than 1.0 indicate slower playback. For example, a value of 2.0 instructs ActiveMovie to play the content at twice its original speed.

Rating Multimedia content may be rated. If a particular media file is rated, this property will contain its rating.

SelectionStart/SelectionEnd Instead of playing an entire media file from start to finish, you can set up a range for the playback. These properties indicate where the playback should start (SelectionStart) and stop (SelectionEnd). When the media content is played, only data between the start and end positions will be played.

ShowDisplay The VCR display at the bottom of the ActiveMovie window can be displayed or hidden by setting this property to TRUE or FALSE, respectively.

ShowPositionControls This property controls whether the position controls for seeking within a file are displayed or hidden. Setting this property's value to TRUE will display the position controls. This is similar to EnablePositionControls; however, this property controls whether the buttons are displayed or hidden. EnablePositionControls either disables or enables those buttons.

ShowSelectionControls Like ShowPositionControls, this property determines whether the additional selection buttons should be displayed (TRUE) or hidden (FALSE).

ShowTracker The slider at the bottom of the ActiveMovie window indicates the current position of the media playback and allows the user to seek to different positions within the file. This slider can be displayed or hidden by setting this property to TRUE or FALSE, respectively.

ShowControls All VCR button controls at the bottom of the ActiveMovie screen can be displayed (TRUE) or hidden (FALSE) by setting this property appropriately.

Title If the currently loaded media file has a title, it's stored as the value for this property.

Volume As you can with balance, it's possible to adjust the volume of the media's playback dynamically. Volume values range from -10000 (minimum volume) to 0 (maximum volume).

####
Methods

Besides being able to read and set properties of an ActiveMovie control, there are several functions or methods that may be invoked. Unlike properties, these methods instruct the ActiveMovie control to perform a particular action instead of simply specifying or retrieving settings. The following is a list of methods available to VBScript for controlling an ActiveMovie control.

Run This method starts the playback of a media file. If the file was stopped, then the Run method starts playing the content again from the beginning or from the beginning of the selection range. If the content is paused, the Run method will continue playback from the point at which it was paused.

Stop This method stops the playback of a media file. When the media content is played again, it will begin at the start of the file or at the starting point for the selection range.

Pause This method pauses the playback of a media file. It's similar to the Stop method, except when the playback is paused, it can resume from the point at which it was paused.

####
Events

Earlier you learned about the property that allows you to specify which events you would like to receive notification for when they occur. Your VBScript routines can then handle these events to perform specific actions. The following list describes the valid events that can be recognized by VBScript for the ActiveMovie control:

Error() When an error occurs in the ActiveMovie control, this event can be triggered. If your VBScript contains a routine to handle this event, you can intercept errors and post your own messages or design code to act accordingly.

PositionChange() This event is triggered when a user changes the current position of the media playback with the tracker control or the seek buttons in the ActiveMovie window. It is not triggered when the CurrentPosition property is updated through VBScript.

StateChange() When the current state of the media playback changes, this event is triggered. A state change may be the event of stopping a media file being played. The CurrentState property can be used to determine the current action of the media player.

Timer() An event can be triggered on a regular basis as determined by the ActiveMovie control. Whenever this event occurs, a VBScript routine can be executed.

###
What's Next

In this chapter, you have learned about Microsoft's ActiveMovie ActiveX control and had an opportunity to learn more about using ActiveX as a video player and controlling playback of media through VBScript. You have also been introduced to the concept of streaming media content, particularly designed for low-bandwidth connections, such as those used for Internet access through a modem. A complete review of the ActiveMovie control interface would clearly extend beyond the scope of this chapter and certainly this book. However, you should now be at least acquainted with the technology and able to use ActiveMovie controls on your own Web pages.

In the next chapters, you will have the opportunity to learn about connecting Web pages with databases on a Web server (Chapters 12 and 13) and how to create an original ActiveX control that can be placed on a Web page (Chapter 11).

| Use of this site is subject certain Terms & Conditions. Copyright (c) 1996-1999 EarthWeb, Inc.. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Please read our privacy policy for details.