Tour the Source Code of the Free ASP.NET QuickTimePlayer
By Steve C. Orr
Playing QuickTime movies from an ASP.NET Web form can be a
little tricky. At first it may not seem difficult, but there are a lot of
little details to worry about such as browser differences, ActiveX
activation, and the list of acceptable parameters. The QuickTimePlayer control
detailed here (and shown in Figure 1) takes care of all those issues, reducing
the task to drag-and-drop simplicity.
Figure 1: The QuickTimePlayer
control eliminates the chores involved with playing QuickTime movies.
During the exploration of this control you re also likely
to learn a lot about custom Web control design, ActiveX activation, and ASP.NET
2.0 Web resources. All major browsers are supported by the QuickTimePlayer
control, including Internet Explorer, Firefox, Safari,
America Online, Opera,
How to Use It
The QuickTimePlayer.dll can be added to your Visual Studio
toolbox via right-click just like any other control (see end of article for
download details). When that task is done, it can be dragged from the toolbox
onto any ASP.NET Web form, where a definition similar to this will be rendered
to the ASPX:
Of course, you can type such a declaration manually, if
preferred. The MOVFile property is the only one you ll definitely need to
adjust, because it defines which QuickTime movie (*.mov) will be played. There
are a variety of other useful properties, as well, including properties for
caching the movie and looping the movie endlessly. The full list of unique
QuickTimePlayer properties is shown in Figure 2.
Specifies whether or not the movie file should
automatically start playing as soon as the page is loaded.
A Boolean property that determines whether to cache the
video file or not.
If this Boolean property is set to True, video will not
be shown; audio only.
When this Boolean property is set to True it will cause
the movie to loop continuously.
Set this string property to the filename of the
QuickTime file that should be played.
If this Boolean property is set to False then the
dropdown/context menu for the control will not be available, disabling the
feature to save the file locally.
QuickTimePlayer control has many properties that allow adjustment of the look
and behavior of the player.
The ShowMenu property can be used to disable the
dropdown/context menu that is normally available in QuickTimePlayer. That menu s
primary feature is to allow the user to save the movie file to a local drive. Set
the ShowMenu property to False to deny users of that feature. (However,
knowledgeable users can still likely use more complex techniques to snag your
The Hidden property can be set to True if you only want to
play audio. No video or user interface will be visible when this property is
set to its non-default value of True.
The AutoPlay property ensures that a movie starts playing
at its first available opportunity. If set to False the movie will load but not
play upon page load, as it normally would. The movie can then be started via
AutoPlay property s default value is True.
With the knowledge you now have about using the
QuickTimePlayer control, you could stop reading here and start developing with
it. But if the developer in you wants to find out the details about the
QuickTimePlayer s inner workings, keep reading ...
How It Works
To play a QuickTime movie on your own (without the aid of
the QuickTimePlayer control), you d include some HTML similar to that shown in Figure
QuickTime movies can be played in most browsers (except Internet Explorer) with
a bit of HTML such as this.
This would work great in virtually all browsers except
Internet Explorer, which requires a completely different syntax. To play a
movie in Internet Explorer, the syntax shown in Figure 4 must be used. However,
if this HTML is placed directly in the page, then ActiveX activation will be
required, annoying users and forcing them to click on the control before they
can interact with it.
Figure 4: Internet
Explorer requires this syntax to play QuickTime movies, but ActiveX activation
will be required if this HTML is embedded directly in the page.
One common technique is to always output both syntaxes. All
browsers will pick the syntax they like and ignore the other one, so it works
without issue. When given a choice, however, I prefer tidy HTML output. I don t
want to waste bandwidth by outputting HTML that is not used. Therefore, the
QuickTimePlayer control only outputs the most appropriate syntax.
Essentially the QuickTimePlayer control detects which
browser the user has and outputs the syntax in Figure 4 for Internet Explorer,
or the syntax shown in Figure 3 for other browsers. The control s private RenderForAlt
subroutine (listed in Figure 5) takes charge of rendering the HTML for non-Internet
Explorer browsers. The resulting output is similar to that shown in Figure 3.
''' Renders QuickTime embed tag for non-IE browsers
Private Sub RenderForAlt(ByVal output As HtmlTextWriter)