TweetFollow Us on Twitter

March 93 - SOMEWHERE IN QUICKTIME

SOMEWHERE IN QUICKTIME

TOP 10 QUICKTIME TIPS

JOHN WANG

[IMAGE 031-033_QuickTime_column1.GIF]



To inaugurate this new column on QuickTime, we'll take a look at ten useful tips for QuickTime application developers. This is certainly not an exhaustive list, but itis  an important one.

Here's the list:
10. Working around data reference limitations.
9. Using GetMovieNextInterestingTime.
8. Not calling ExitMovies.
7. Getting a movie's unscaled size.
6. Avoiding the Movie Toolbox when using the standard movie controller.
5. Prerolling a movie for improved playback.
4. Using CustomGetFilePreview with custom dialogs.
3. Conditionally registering a component that requires a hardware device.
2. Detaching a movie controller properly.
1. Calling MaxApplZone from every application.

Some of the tips describe pitfalls that need to be avoided, while others are simply clarifications. Let's take a closer look at each one.

10. Working around data reference limitations.

A current limitation of QuickTime is that each media can have only one data reference to a media data file. This isn't a problem except when you start cutting and pasting between tracks that refer to different media. You'll then be required to copy the media data from one media data file to another. For example, InsertTrackSegment will copy media data between media if the tracks refer to different media.

Calls like GetMediaDataRefCount, AddMediaDataRef, and GetMediaDataRef will reflect the "one data reference" limitation by only accepting index values of 1. You can't replace an existing media data reference in QuickTime 1.0, but you can in QuickTime 1.5, with a new call, SetMediaDataRef. Using this routine is a common way of manuallyresolving media data references that may have been moved by an application. For example, if you move a movie data file onto a different volume, you can update the alias using the Alias Manager and update the data reference for the movie with SetMediaDataRef.

9. Using GetMovieNextInterestingTime.

Since QuickTime is time based rather than frame-number based in the way it deals with temporal video data, a common question is how to get information about movie frames, such as frame rate. The answer is to use GetMovieNextInterestingTime. This function allows you to step quickly and easily through interesting times in a movie. For example, for an estimate of the frame rate of a movie, you could use GetMovieNextInterestingTime to count the total number of frames in the movie and divide it by the total duration of the movie. Likewise, you could use GetMovieNextInterestingTime to identify the 600th frame in a movie. Since the internal data structure of QuickTime movies is optimized for accessing this type of information, GetMovieNextInterestingTime and the other GetNextInterestingTime calls are very efficient.

8. Not calling ExitMovies.

One recommendation that contradicts QuickTime 1.0 documentation is that applications should not call ExitMovies before quitting. QuickTime calls this function at ExitToShell time, and it's safer to allow QuickTime to release private storage and component connections at that time. This prevents problems such as closing components in the wrong order. For example, the proper way to clean up after a movie that uses a standard movie controller is to dispose of the movie controller first, and then dispose of the movie. If done in the reverse order, there may be adverse consequences.

7. Getting a movie's unscaled size.

An application should save the movie box obtained with GetMovieBox when a movie is loaded so that it can retrieve the intended offset and scaling of the movie for playback. However, some applications may also want to get the unscaled size, and there isn't an intuitive way to get it. Since the programmatical effect of calling SetMovieBox is that the movie matrix is changed to reflect the new offset and scaling, you can easily get the movie box for an unscaled movie by setting the movie matrix to the identity matrix; using the utility routine SetIdentityMatrix along with SetMovieMatrix accomplishes this. Then GetMovieBox will return the unscaled size and offsets.

However, there's a loophole. If a track inside the movie is scaled, there may still be scaling in playback since QuickTime supports transformation matrices for movies and for tracks within a movie. Therefore, when working with scaling, applications need to pay attention not only to the movie's scaling but to the tracks' scaling as well.

6. Avoiding the Movie Toolbox when using the standard movie controller.

When using the standard movie controller, you should almost never use any Movie Toolbox routines that control movie playback or change movie characteristics. For example, it would be a mistake to call StartMovie to start playing a movie. Instead, use the movie controller equivalent, MCDoAction with mcActionPlay. Calling StartMovie directly causes the movie to play but with the controller's button in the pause state, not reflecting that the movie is playing back. Similarly, to set looping, you would use MCDoAction with mcActionSetLooping. Bypassing the movie controller by using the Movie Toolbox routines directly on a movie controlled with a movie controller can have dire consequences. As an example, if you set looping for a movie before creating a controller with NewMovieController, you'll cause the Macintosh to crash. Don't let it happen to you!

5. Prerolling a movie for improved playback.

Prerolling can improve playback performance by allowing QuickTime to do preliminary initialization. Since PrerollMovie is passed the movie time and rate, it can fill buffers and caches optimally to prevent initial stuttering. Normally, QuickTime automatically prerolls the movie for you. For example, if you call StartMovie, you don't need to also call PrerollMovie, since StartMovie prerolls the movie for you. The QuickTime 1.5 documentation describing the StartMovie call states this clearly. Likewise, the standard movie controller is optimized to preroll whenever the user starts a movie with the keyboard or mouse. If you call PrerollMovie in these situations, the second PrerollMovie is redundant and will simply waste time. In all other cases, prerolling by calling PrerollMovie is recommended before initiating playback. For example, you should call PrerollMovie before SetMovieRate.

4. Using CustomGetFilePreview with custom dialogs.

If you use CustomGetFilePreview with custom DLOG and DITL resources, you should be aware of a bug with the System 7 pop-up menu CDEF: pop-up menus used in conjunction with black-and- white grafPorts are shifted to the wrong location within the dialog box. The simple workaround is to force the dialog to be a cGrafPort by adding a 'dctb' resource with the same ID as the DLOG and DITL resources. You can easily create a 'dctb' resource with ResEdit by selecting the Custom color button in the DLOG resource template window. For more information on the 'dctb' resource, see the Dialog Manager chapter inInside Macintosh: Macintosh Toolbox Essentials (or in Inside Macintosh Volume V).

3. Conditionally registering a component that requires a hardware device.

If you write a component that requires a hardware device, you should set the wantsRegisterMessage flag to give your component an opportunity to verify that the specific hardware is properly installed. If the hardware isn't available, you can then indicate to the Component Manager that you don't want the component registered. The register routine, called with selector kComponentRegister, should return FALSE if it does want to be registered and TRUE if it doesn't.

One thing to be aware of is that even during registration, the component will be opened with OpenComponent and closed with CloseComponent. Therefore, you can expect OpenComponent before the ComponentRegister routine is called, and CloseComponent after ComponentRegister is called.

For example, if you have a 'vdig' that works with a NuBus video digitizer card, each time that OpenComponent is called you can check whether the hardware is correctly installed, and then return that status when ComponentRegister is called by the Component Manager.

2. Detaching a movie controller properly.

If you want to place the standard movie controller in a different window or location from its usual placement directly below the movie, you must detach the movie controller. Follow these steps:

  1. First bring up the controller by calling NewMovieController with the flag mcNotVisible so that the controller is initially invisible. If you don't do this, the application will momentarily display the controller in the wrong location.
  2. Call MCSetControllerAttached with FALSE to detach the controller.
  3. Call MCSetControllerPort to move the controller to a different port if you want to place it in a different window. If you only want to move the controller in the same window as the movie, you don't have to call MCSetControllerPort.
  4. Call either MCPositionController or MCSetControllerBoundsRect to move the controller to the new location in the port.
  5. Call MCSetVisible to display the controller.

The movie will remain in whatever port it was assigned to using SetMovieGWorld. If MCSetControllerPort isn't called (step 3), the controller will remain assigned to the movie's port when NewMovieController is called.

For example:

SetMovieGWorld(myMovie, (CGrafPtr) myWindow, 0);
mcMC = NewMovieController(myMovie, &movieBounds,
    mcTopLeftMovie + mcNotVisible);
MCSetControllerAttached(mcMC, FALSE);
MCSetControllerPort(mcMC, myOtherWindow);
MCPositionController(myMC, &movieBounds,
    &newControllerRect, mcTopLeftMovie);
MCSetVisible(myMC, TRUE);

1. Calling MaxApplZone from every application.

Not calling MaxApplZone in an application is the reason why many simple QuickTime playback applications play back movies poorly. Because the Memory Manager grows the heap only if there isn't any purgeable or free space left, QuickTime doesn't have the space it needs to play back a movie optimally. Since there's no penalty or drawback for calling MaxApplZone, all applications should call the routine during initialization. In fact, MaxApplZone should be your first Macintosh Toolbox call, because initializing QuickDraw and other managers could allocate memory.

We hope these tips will help you avoid some of the most common pitfalls of QuickTime development. With so many developers writing QuickTime applications and adding QuickTime support into existing applications, we want the journey to be as smooth as possible. We'll keep you updated and informed by continuing to bring you insightful tips and details about QuickTime in this column. Watch for it!


JOHN WANG (AppleLink WANG.JY) is enjoying his youth in the playpen of the Printing, Imaging, and Graphics (PIGs) group in Developer Technical Support at Apple. When he's not engaged in piglet activities, he can be found on a golf course or hogging the road with his Mazda Miata. No one has trouble identifying John's car, since he often cruises the California highways with his dog, Skate. In return, Skate promises to drive safely. *

For more information on the Component Manager, see the QuickTime or System 7.1 documentation on this subject, and see Gary Woodcock and Casey King's article, "Techniques for Writing and Debugging Components," in develop  Issue 12. *



Thanks to the developers who have made this list possible and to Bill Guschwan, Peter Hoddie, and Guillermo Ortiz for reviewing this column. *

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Seven Knights Idle Adventure drafts in a...
Seven Knights Idle Adventure is opening up more stages, passing the 15k mark, and players may find themselves in need of more help to clear these higher stages. Well, the cavalry has arrived with the introduction of the Legendary Hero Iris, as... | Read more »
Fallout Shelter pulls in ten times its u...
When the Fallout TV series was announced I, like I assume many others, assumed it was going to be an utter pile of garbage. Well, as we now know that couldn't be further from the truth. It was a smash hit, and this success has of course given the... | Read more »
Recruit two powerful-sounding students t...
I am a fan of anime, and I hear about a lot that comes through, but one that escaped my attention until now is A Certain Scientific Railgun T, and that name is very enticing. If it's new to you too, then players of Blue Archive can get a hands-on... | Read more »
Top Hat Studios unveils a new gameplay t...
There are a lot of big games coming that you might be excited about, but one of those I am most interested in is Athenian Rhapsody because it looks delightfully silly. The developers behind this project, the rather fancy-sounding Top Hat Studios,... | Read more »
Bound through time on the hunt for sneak...
Have you ever sat down and wondered what would happen if Dr Who and Sherlock Holmes went on an adventure? Well, besides probably being the best mash-up of English fiction, you'd get the Hidden Through Time series, and now Rogueside has announced... | Read more »
The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »

Price Scanner via MacPrices.net

13-inch M3 MacBook Airs on sale for $100 off...
Best Buy has Apple 13″ MacBook Airs with M3 CPUs in stock and on sale today for $100 off MSRP. Prices start at $999. Their prices, along with Amazon’s, are the lowest currently available for new 13″... Read more
Amazon is offering a $100 discount on every 1...
Amazon has every configuration and color of Apple’s 13″ M3 MacBook Air on sale for $100 off MSRP, now starting at $999 shipped. Shipping is free: – 13″ MacBook Air (8GB RAM/256GB SSD): $999 $100 off... Read more
Sunday Sale: Take $150 off every 15-inch M3 M...
Amazon is now offering a $150 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 15″ M3 MacBook... Read more
Apple’s 24-inch M3 iMacs are on sale for $150...
Amazon is offering a $150 discount on Apple’s new M3-powered 24″ iMacs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 24″ M3 iMac/8-core GPU/8GB/256GB: $1149.99, $150 off... Read more
Verizon has Apple AirPods on sale this weeken...
Verizon has Apple AirPods on sale for up to 31% off MSRP on their online store this weekend. Their prices are the lowest price available for AirPods from any Apple retailer. Verizon service is not... Read more
Apple has 15-inch M2 MacBook Airs available s...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs available starting at $1019 and ranging up to $300 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at Apple.... Read more
May 2024 Apple Education discounts on MacBook...
If you’re a student, teacher, or staff member at any educational institution, you can use your .edu email address when ordering at Apple Education to take up to $300 off the purchase of a new MacBook... Read more
Clearance 16-inch M2 Pro MacBook Pros in stoc...
Apple has clearance 16″ M2 Pro MacBook Pros available in their Certified Refurbished store starting at $2049 and ranging up to $450 off original MSRP. Each model features a new outer case, shipping... Read more
Save $300 at Apple on 14-inch M3 MacBook Pros...
Apple has 14″ M3 MacBook Pros with 16GB of RAM, Certified Refurbished, available for $270-$300 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year warranty is... Read more
Apple continues to offer 14-inch M3 MacBook P...
Apple has 14″ M3 MacBook Pros, Certified Refurbished, available starting at only $1359 and ranging up to $270 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year... Read more

Jobs Board

Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
*Apple* App Developer - Datrose (United Stat...
…year experiencein programming and have computer knowledge with SWIFT. Job Responsibilites: Apple App Developer is expected to support essential tasks for the RxASL Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple 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.