Changeset 533
- Timestamp:
- 06/01/09 04:45:33 (16 years ago)
- Location:
- trunk/Cocoa/Pester/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/English.lproj/MainMenu.nib/classes.nib
r528 r533 175 175 <dict> 176 176 <key>preview</key> 177 <string> NSMovieView</string>177 <string>QTMovieView</string> 178 178 </dict> 179 179 <key>SUPERCLASS</key> … … 200 200 <string>ObjC</string> 201 201 <key>SUPERCLASS</key> 202 <string> NSMovieView</string>202 <string>QTMovieView</string> 203 203 </dict> 204 204 <dict> -
trunk/Cocoa/Pester/Source/English.lproj/MainMenu.nib/info.nib
r528 r533 11 11 <key>IBOpenObjects</key> 12 12 <array> 13 <integer> 2</integer>13 <integer>507</integer> 14 14 </array> 15 15 <key>IBSystem Version</key> -
trunk/Cocoa/Pester/Source/NJRQTMediaPopUpButton.h
r133 r533 8 8 9 9 #import <AppKit/AppKit.h> 10 #import <QTKit/QTKit.h> 10 11 #import "BDAlias.h" 11 12 … … 13 14 14 15 @interface NJRQTMediaPopUpButton : NSPopUpButton { 15 IBOutlet NSMovieView *preview;16 IBOutlet QTMovieView *preview; 16 17 BOOL movieCanRepeat, movieHasAudio; 17 18 NSMenuItem *otherItem; -
trunk/Cocoa/Pester/Source/NJRQTMediaPopUpButton.m
r355 r533 14 14 #import <QTKit/QTKit.h> 15 15 16 #include <QuickTime/Movies.h>17 16 #include <limits.h> 18 17 … … 25 24 - (NSMenuItem *)_itemForAlias:(BDAlias *)alias; 26 25 - (BOOL)_validateWithPreview:(BOOL)doPreview; 27 - (void)_updateOutputVolume;28 26 - (void)_startSoundPreview; 27 - (void)_resetPreview; 28 - (void)_resetOutputVolume; 29 29 @end 30 30 … … 304 304 if ([preview movie] == nil) { 305 305 [self _validateWithPreview: YES]; 306 } else { // don't restart preview if already playing307 [self _ updateOutputVolume];306 } else { 307 [self _startSoundPreview]; 308 308 } 309 309 } … … 318 318 } 319 319 320 - (void)_updateOutputVolume; 321 { 322 if ([preview movie] != nil && outputVolume != kNoVolume) { 323 if (!savedVolume && ![NJRSoundManager saveDefaultOutputVolume]) 324 return; 320 - (void)_startSoundPreview; 321 { 322 if ([preview movie] == nil || outputVolume == kNoVolume) 323 return; 324 325 if (savedVolume || [NJRSoundManager saveDefaultOutputVolume]) { 325 326 savedVolume = YES; 326 327 [NJRSoundManager setDefaultOutputVolume: outputVolume]; 327 if (![preview isPlaying]) [self _startSoundPreview]; 328 } 328 } 329 330 if ([[preview movie] rate] != 0) 331 return; // don't restart preview if already playing 332 333 [[NSNotificationCenter defaultCenter] addObserver: self 334 selector: @selector(_soundPreviewDidEnd:) 335 name: QTMovieDidEndNotification 336 object: [preview movie]]; 337 [preview play: self]; 338 } 339 340 - (void)_soundPreviewDidEnd:(NSNotification *)notification; 341 { 342 [self _resetPreview]; 343 } 344 345 - (void)_resetPreview; 346 { 347 [preview setMovie: nil]; 348 [self _resetOutputVolume]; 329 349 } 330 350 … … 335 355 } 336 356 337 - (void)_resetPreview;338 {339 // if we donÕt do this after the runloop has finished, then we crash in MCIdle because itÕs expecting a movie and doesnÕt have one any more340 [preview setMovie: nil]; // otherwise we get an extra runloop timer which uses a lot of CPU from +[NSMovieView _idleMovies]341 // need to wait for runloop to stop movie, otherwise we're still playing at the time the volume changes342 [self performSelector: @selector(_resetOutputVolume) withObject: nil afterDelay: 0];343 }344 345 void346 MovieStoppedCB(QTCallBack cb, long refCon)347 {348 NJRQTMediaPopUpButton *self = (NJRQTMediaPopUpButton *)refCon;349 // avoid multiple messages from multiple movie playback cycles in the same runloop350 [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(_resetPreview) object: nil];351 [self performSelector: @selector(_resetPreview) withObject: nil afterDelay: 0];352 DisposeCallBack(cb);353 }354 355 - (void)_startSoundPreview;356 {357 Movie qtMovie = [[preview movie] QTMovie];358 QTCallBack cbStop = NewCallBack(GetMovieTimeBase(qtMovie), callBackAtExtremes);359 QTCallBackUPP cbStopUPP = NewQTCallBackUPP(MovieStoppedCB);360 OSErr err = CallMeWhen(cbStop, cbStopUPP, (long)self, triggerAtStop, 0, 0);361 if (err != noErr) {362 NSLog(@"Can't register QuickTime stop timebase callback for preview: %ld", err);363 DisposeCallBack(cbStop);364 }365 [preview start: self];366 }367 368 357 - (BOOL)_validateWithPreview:(BOOL)doPreview; 369 358 { 370 [preview stop: self];359 [preview pause: self]; 371 360 if (selectedAlias == nil) { 372 361 [preview setMovie: nil]; … … 382 371 movieCanRepeat = ![movie isStatic]; 383 372 if (movieHasAudio = [movie hasAudio]) { 384 [preview setMovie: doPreview ? movie : nil]; 385 [self _updateOutputVolume]; 373 [preview setMovie: doPreview ? [QTMovie movieWithURL: [NSURL fileURLWithPath: [selectedAlias fullPath]] error: NULL] : nil]; // XXX handle errors; fix 386 374 } else { 387 375 [self _resetPreview]; … … 412 400 - (IBAction)stopSoundPreview:(id)sender; 413 401 { 414 [preview stop: self];402 [preview pause: self]; 415 403 [self _resetPreview]; 416 404 } -
trunk/Cocoa/Pester/Source/NJRUnfocusableMovieView.h
r53 r533 8 8 9 9 #import <AppKit/AppKit.h> 10 #import <QTKit/QTKit.h> 10 11 11 12 @interface NJRUnfocusableMovieView : NSMovieView { 12 @interface NJRUnfocusableMovieView : QTMovieView { 13 13 14 14 }
Note:
See TracChangeset
for help on using the changeset viewer.