TweetFollow Us on Twitter

The Sting

Volume Number: 19 (2003)
Issue Number: 4
Column Tag: QuickTime Toolkit

The Sting

Developing QuickTime Applications with "Stinger"

by Tim Monroe

Introduction

In the previous QuickTime Toolkit article ("The Vision" in MacTech, March 2003), we took a look at developing QuickTime applications using Microsoft's Visual Basic. I noted then that Visual Basic provides no built-in support for displaying or editing or creating QuickTime movies, but that we can work with QuickTime movies using any one of several third-party ActiveX components. Apparently that article struck a nerve somewhere within Microsoft, for several days after the magazine hit the stands, I received a package -- postmarked in Redmond, Washington but otherwise with no indication of the sender -- containing a single CD. The CD contains what appears to be a pre-release version of a multimedia application framework developed by Microsoft. The product is named "Stinger" and sports a logo of a bee (which is eerily reminiscent of the MSN butterfly).

So far, I've spent only a couple of days working with Stinger, but it's clearly a software development environment of some importance for QuickTime developers. It allows us to write applications that support the standard litany of Microsoft proprietary media and file formats (AVI, WMV7, ASF); Stinger also supports MPEG-4 audio and video formats. This already is pretty surprising, as it represents an abrupt shift on Microsoft's behalf toward open standards for multimedia content. What's even more surprising is that we can use Stinger to develop applications that can create, open, and display QuickTime movies. And the list of operating systems that can run Stinger-developed applications is truly amazing; Stinger can create multimedia applications that run on Windows, Mac OS, several flavors of Linux, Palm OS, and even MS-DOS itself! For instance, Figure 1 shows the QuickTime sample movie displayed by an application running under Red Hat Linux; note the distinctive Red Hat "Bluecurve" graphical interface.


Figure 1: A QuickTime movie playing in Red Hat Linux

In this article, we're going to take a preliminary and unfortunately brief look at Stinger. I should say in advance that the information here is derived mainly from my own tinkering around with it (there was no documentation on the CD), and some of it is pure conjecture. Also, the name "Stinger" is quite likely a code name -- though judging from the professional finish to the logo, the final product name will probably have some apiary connection ("Visual Beesic" perhaps?).

Microsoft and QuickTime

Perhaps the most amazing thing about Stinger is that it exists at all. I noted in the previous article that "Microsoft...does not have a history of promoting QuickTime as a multimedia creation or delivery technology". That was an understatement. In fact, Microsoft has a history of trying to derail the adoption of QuickTime, at least on Windows operating systems. Here is an excerpt from the court's decision in the recent Justice Department anti-trust case against Microsoft:

    "S. 105. Beginning in the spring of 1997 and continuing into the summer of 1998, Microsoft tried to persuade Apple to stop producing a Windows 95 version of its multimedia playback software, which presented developers of multimedia content with alternatives to Microsoft's multimedia APIs. If Apple acceded to the proposal, Microsoft executives said, Microsoft would not enter the authoring business and would instead assist Apple in developing and selling tools for developers writing multimedia content....Apple would have been permitted, without hindrance, to market a media player that would run on top of DirectX. But...Apple's QuickTime shell would not have exposed platform-level APIs to developers. Microsoft executives acknowledged to Apple their doubts that a firm could make a successful business out of marketing such a shell." (From the Court's Findings of Fact, Civil Action No. 98-1232.)

At one meeting in April 1997, Apple engineer Peter Hoddie asked incredulously: "Are you asking us to kill playback? Are you asking us to knife the baby?" According to court testimony, a Microsoft official responded: "Yes, we want you to knife the baby." Ouch. (Insider trivia factoid: this exchange prompted a member of the QuickTime engineering team to print up tee-shirts bearing the slogan "Don't Knife the Baby.")

It gets worse. Some early versions of Microsoft's multimedia playback application, the Windows Media Player (also known affectionately and perhaps too accurately as WiMP), had a tendency to hijack the QuickTime movie MIME type (that is, "video/quicktime"). When a Windows user would navigate to a web site containing embedded QuickTime files (with the file extension .mov), the movie files would be opened by WiMP, not by the QuickTime plug-in. For most media types, and particularly for QuickTime VR movies, this would result in a less than optimal experience.

Further, Internet Explorer version 6.0 (which was first shipped with Windows XP) and version 5.5 with Service Pack 2 applied broke browser-based QuickTime movie playback altogether. That was because those versions of IE stopped supporting NetScape-style plug-ins and because the QuickTime plug-in was implemented as a NetScape-style plug-in. Indeed, it was precisely to address this issue that Apple developed (with Microsoft's assistance, it must be pointed out) the Apple QuickTime ActiveX control that we investigated in the previous article.

I could continue down this road ad nauseum, but the fact is that I come to praise Microsoft, not to bury it. After all, as I've suggested, Stinger represents a complete reversal of this "knife the baby" strategy. So, in quasi-Watergate style, let's follow the honey.

Stinger Overview

The CD I received contains two folders, one labeled "Runtime Installers" and the other labeled "DevStudio Installers". The first folder contains what appear to be runtime environment installers for the target platforms (more on this later). The second folder contains only a single executable file, StngrInstl.exe. After running the application, I launched Microsoft Visual C++ Developer Studio and was greeted with the "Tip of the Day" shown in Figure 2.


Figure 2: A Visual Studio Tip of the Day

Dutifully, I selected the New menu item in the File menu. Sure enough, the list of available projects included "QuickTime Application" and "QuickTime Component", as shown in Figure 3. Clicking on "QuickTime Application" revealed that Stinger can generate QuickTime-savvy applications for seven different platforms: Windows, Mac OS 9, Mac OS X, Palm OS, Red Hat Linux, Mandrake Linux, and MS-DOS. I was, to put it mildly, intrigued.


Figure 3: The New Project dialog box

I named the new project "StingerShell". Recall that our goal in this current series of articles is to replicate the functionality of our existing application QTShell. On Windows, QTShell provides support for opening multiple QuickTime movie files and displaying them in child windows inside an enclosing frame window. In other words, QTShell on Windows uses the Multiple Document Interface (MDI). It turns out that the default applications created by Stinger use the Single Document Interface (SDI): they open QuickTime movies in a window whose content area completely contains the movie and the movie controller bar. (The size of the movie within the content area can be adjusted, but for present purposes we don't need to do so.) So the only thing we need to do to bring the default Windows application into line with an SDI version of QTShell is add the Test menu -- where we add our application-specific items -- and add some code to handle those menu items.

Adding Menu Items

The programming model supported by Stinger is unexciting: it's straight C code that calls Windows APIs for basic application services (event handling, message processing, and so forth) and QuickTime APIs for multimedia services. Listing 1 shows the code that is called when the user selects a movie in the file-opening dialog box.

Listing 1: Opening a QuickTime movie file

OpenMovie
void OpenMovie (HWND hwnd, char *szFileName)
{
   short      nFileRefNum = 0;
   FSSpec      fss; 
   NativePathNameToFSSpec(szFileName, &fss, 0);
   SetGWorld((CGrafPtr)GetNativeWindowPort(hwnd), NULL); 
   OpenMovieFile(&fss, &nFileRefNum, fsRdPerm);
   NewMovieFromFile(&sMovie, nFileRefNum, NULL, NULL,
            newMovieActive, NULL); 
   CloseMovieFile(nFileRefNum);
}

The only interesting departure from the standard Windows programming model that we've worked with throughout this series of articles concerns the specification of the application's resources. The default project contains a file StingerShell.sc that defines the application's menus, icons, text strings, and dialog box layouts. This .sc file is analogous to the .rc files we've worked with previously, but supports additional resource compiler directives necessary to support deployment on different platforms. Listing 2 shows how we can add in the Test menu but -- for Palm applications only -- exclude the Help menu.

Listing 2: Specifying the application's menus and menu items

StingerShell.sc
IDR_MAINFRAME MENU PRELOAD DISCARDABLE 
BEGIN
   POPUP "&File"
   BEGIN
      MENUITEM "&New\tCtrl+N",            ID_FILE_NEW
      MENUITEM "&Open...\tCtrl+O",        ID_FILE_OPEN
      MENUITEM "&Close\tCtrl+W",          ID_FILE_CLOSE
      MENUITEM SEPARATOR
      MENUITEM "&Save\tCtrl+S",           ID_FILE_SAVE
      MENUITEM "Save &As...",             ID_FILE_SAVE_AS
      MENUITEM SEPARATOR
      MENUITEM "E&xit\tCtrl+Q",           ID_APP_EXIT
   END
   POPUP "&Edit"
   BEGIN
      MENUITEM "&Undo\tCtrl+Z",           ID_EDIT_UNDO
      MENUITEM SEPARATOR
      MENUITEM "Cu&t\tCtrl+X",            ID_EDIT_CUT
      MENUITEM "&Copy\tCtrl+C",           ID_EDIT_COPY
      MENUITEM "&Paste\tCtrl+V",          ID_EDIT_PASTE
      MENUITEM "C&lear",                  ID_EDIT_CLEAR
      MENUITEM SEPARATOR
   MENUITEM "Select &All\tCtrl+A",        ID_EDIT_SELECTALL
   END
   POPUP "&Test"
   BEGIN
      MENUITEM "&Hide Controller Bar\tCtrl+1",
                                          ID_TEST_HIDE_CTRL
      MENUITEM "&Hide Speaker Button\tCtrl+2",
                                          ID_TEST_HIDE_SPKR
   END
#if !TARGET_OS_PALM
   POPUP "&Help"
   BEGIN
      MENUITEM "&About StingerShell...",   ID_APP_ABOUT
   END
#endif
END

The code required to handle our application-specific menu items is, once again, completely unexciting. I'll leave it as an exercise for the interested reader to dredge up a past issue of MacTech to see how it works.

Building and Running the Applications

Now let's build the applications. Select "Build StingerShell" in the Build menu (or press the F7 key). Once the build process completes, the Debug folder will contain the usual collection of object files and other junk; it will also contain debug builds of StingerShell for the target platforms. If we launch the Windows application StingerShell.exe, we'll see the error window shown in Figure 4.


Figure 4: A runtime error message

This is where the installers in the "Runtime Installers" folder come into play. Let's run the installer WinHiveInstl.exe. Once we've done this, we can try launching StingerShell.exe again. This time, everything proceeds as expected. The movie playback window is shown in Figure 5.


Figure 5: A QuickTime movie playing under Windows

We can transfer the other compiled applications (and runtime installers) to their target operating systems. The file StingerShell.app is a Carbon application that can run on Mac OS 9 or Mac OS X. Figure 6 shows StingerShell running under Mac OS X.


Figure 6: A QuickTime movie playing under Mac OS X

The file StingerShell.rhl is the executable for Red Hat Linux (see Figure 1 again). The file StingerShell.ml is the executable for Mandrake Linux (Figure 7).


Figure 7: A QuickTime movie playing under Mandrake Linux

Apparently there is already a PalmOS application with the trademarked name StingerShell, so I've renamed the Palm application QTShell.prc. When we download the executable to a Palm device, we'll see it in the list of available programs, as shown in Figure 8.


Figure 8: QTShell in the list of Palm programs

Figure 9 shows QTShell running on the Palm device.


Figure 9: A QuickTime movie playing under PalmOS

Conclusion

This is all very cool, but how does it work? Apple provides QuickTime runtime support only for Macintosh and Windows operating systems. How can we run QuickTime applications on Linux and Palm systems as well? This is where I'm reduced to pure speculation. As we've seen, our compiled applications would not run without the prior installation of the so-called ".HIVE" runtime environment. I'm guessing that this is some sort of multimedia extension to Microsoft's .NET environment. Apparently Microsoft has shoehorned the QuickTime libraries into the platform-specific .HIVE interpreters and also provided some sort of emulation layer for those platforms that do not natively support QuickTime. Or so I'm guessing. If I had more time and a good debugger, I could probably figure out more of what's happening under the hood.

No matter how it works, it's clear that indeed it does work. It's sad to realize that Microsoft has beaten Apple to the punch in supporting QuickTime movie playback on Palm devices and on Linux platforms. The performance is not good (I was able to achieve a playback rate of only about 0.5 frames per second on a Palm device, and only about 2.5 fps under the Linux systems), but the API coverage appears to be fairly complete. Sigh.

Credits and Retractions

Special thanks are due to an unknown source within Microsoft for providing a pre-release copy of Stinger.

You may have noticed that QuickTime Toolkit articles sport titles borrowed from movies (appropriate for a series on QuickTime, eh?). Perhaps a better title for the present article would have been the 1969 Jack Lemmon and Catherine Deneuve comedy, "The April Fools".


Tim Monroe in a member of the QuickTime engineering team. You can contact him at monroe@apple.com. The views expressed here are not necessarily shared by his employer.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.