Changeset 533 for trunk/Cocoa/Pester


Ignore:
Timestamp:
06/01/09 04:45:33 (15 years ago)
Author:
Nicholas Riley
Message:

Restore sound selector; move most of the preview functionality (excluding validation) to QTKit as NSMovieView and QuickTime are deprecated. Hopefully this will improve stability as well.

Location:
trunk/Cocoa/Pester/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/English.lproj/MainMenu.nib/classes.nib

    r528 r533  
    175175                        <dict>
    176176                                <key>preview</key>
    177                                 <string>NSMovieView</string>
     177                                <string>QTMovieView</string>
    178178                        </dict>
    179179                        <key>SUPERCLASS</key>
     
    200200                        <string>ObjC</string>
    201201                        <key>SUPERCLASS</key>
    202                         <string>NSMovieView</string>
     202                        <string>QTMovieView</string>
    203203                </dict>
    204204                <dict>
  • trunk/Cocoa/Pester/Source/English.lproj/MainMenu.nib/info.nib

    r528 r533  
    1111        <key>IBOpenObjects</key>
    1212        <array>
    13                 <integer>2</integer>
     13                <integer>507</integer>
    1414        </array>
    1515        <key>IBSystem Version</key>
  • trunk/Cocoa/Pester/Source/NJRQTMediaPopUpButton.h

    r133 r533  
    88
    99#import <AppKit/AppKit.h>
     10#import <QTKit/QTKit.h>
    1011#import "BDAlias.h"
    1112
     
    1314
    1415@interface NJRQTMediaPopUpButton : NSPopUpButton {
    15     IBOutlet NSMovieView *preview;
     16    IBOutlet QTMovieView *preview;
    1617    BOOL movieCanRepeat, movieHasAudio;
    1718    NSMenuItem *otherItem;
  • trunk/Cocoa/Pester/Source/NJRQTMediaPopUpButton.m

    r355 r533  
    1414#import <QTKit/QTKit.h>
    1515
    16 #include <QuickTime/Movies.h>
    1716#include <limits.h>
    1817
     
    2524- (NSMenuItem *)_itemForAlias:(BDAlias *)alias;
    2625- (BOOL)_validateWithPreview:(BOOL)doPreview;
    27 - (void)_updateOutputVolume;
    2826- (void)_startSoundPreview;
     27- (void)_resetPreview;
     28- (void)_resetOutputVolume;
    2929@end
    3030
     
    304304    if ([preview movie] == nil) {
    305305        [self _validateWithPreview: YES];
    306     } else { // don't restart preview if already playing
    307         [self _updateOutputVolume];
     306    } else {
     307        [self _startSoundPreview];
    308308    }
    309309}
     
    318318}
    319319
    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]) {
    325326        savedVolume = YES;
    326327        [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];
    329349}
    330350
     
    335355}
    336356
    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 more
    340     [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 changes
    342     [self performSelector: @selector(_resetOutputVolume) withObject: nil afterDelay: 0];
    343 }
    344 
    345 void
    346 MovieStoppedCB(QTCallBack cb, long refCon)
    347 {
    348     NJRQTMediaPopUpButton *self = (NJRQTMediaPopUpButton *)refCon;
    349     // avoid multiple messages from multiple movie playback cycles in the same runloop
    350     [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 
    368357- (BOOL)_validateWithPreview:(BOOL)doPreview;
    369358{
    370     [preview stop: self];
     359    [preview pause: self];
    371360    if (selectedAlias == nil) {
    372361        [preview setMovie: nil];
     
    382371        movieCanRepeat = ![movie isStatic];
    383372        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
    386374        } else {
    387375            [self _resetPreview];
     
    412400- (IBAction)stopSoundPreview:(id)sender;
    413401{
    414     [preview stop: self];
     402    [preview pause: self];
    415403    [self _resetPreview];
    416404}
  • trunk/Cocoa/Pester/Source/NJRUnfocusableMovieView.h

    r53 r533  
    88
    99#import <AppKit/AppKit.h>
     10#import <QTKit/QTKit.h>
    1011
    11 
    12 @interface NJRUnfocusableMovieView : NSMovieView {
     12@interface NJRUnfocusableMovieView : QTMovieView {
    1313
    1414}
Note: See TracChangeset for help on using the changeset viewer.