source: releases/Pester/1.1b4/Source/PSMovieAlertController.m@ 242

Last change on this file since 242 was 133, checked in by Nicholas Riley, 22 years ago

VERSION: Updated for 1.1b4.

PSMovieAlertController.[hm]: Set output volume from alert; save and
restore output volume (bug 27).

PSBeepAlert.[hm]: Save and set volume, disabled pending a
synchronous equivalent to NSBeep().

NJRQTMediaPopUpButton.[hm]: Save movieHasAudio (does not include
beeps, pending the above fix, since they don't permit volume
adjustment). savedVolume indicates whether the volume has been saved
but not restored yet; outputVolume stores the set volume (eventually
incorporated into a PSMediaAlert).

PSMediaAlert.[hm]: Stores repetitions and volume information for audio
alerts. New superclass of PSBeepAlert and PSMovieAlert.

PSPreferencesController.m: Fixed bug where hot keys still appeared
even after they couldn't be set - last of bug 29. Add Command-comma
to the list of disallowed equivalents, as it's reserved for
Preferences now (still a bug - it'll show the entire set key
equivalent at the left side of the window when you press
command-comma; ah well.)

Volume [0123].png: Volume-indicating small icons from QuickTime 6.

NJRSoundManager.[hm]: Interface to volume saving, restoring, setting -
necessary because the QuickTime call to SetDefaultOutputVolume sets
the right channel volume only (bug 27).

PSVolumeController.h: Controller for volume popup window (bug 27).
Not your average NSWindowController, but it works. Keyboard control
of volume is still necessary; filed as bug 31.

PSAlarmSetController.[hm]: Added references to sound volume button and
showVolume: action. Added volume setting support (bug 27); mostly
similar interface to calendar, though we need direct calls to
NJRSoundManager to restore sound volume at times. Only enable sound
volume button if selected media file has audio component (and isn't the
system alert sound, which I discussed above). Take advantage of
PSMediaAlert to factor some code in _readAlerts:. Save and restore
volume as part of alerts.

Read Me.rtfd: Updated release notes; fixed some bizarre text
formatting problems; search/replace "* " bullet-space with "*\t"
bullet-tab to improve alignment in release notes.

PSMovieAlert.[hm]: Factored code into PSMediaAlert. Describe output
volume as percentage of maximum.

NJRHotKey.m: Fixed some odd spacing left over from Ecky's code.

PSApplication.m: Restore saved output volume on quit.

English.lproj/MainMenu.nib: Added volume button.

English.lproj/Volume.nib: Volume nib (bug 27).

PSCalendarController.m: Removed casts from a copy/paste error. Fixed
variable names in some code inherited from my TextExtras incremental
search modifications - it's not always a text field now.

File size: 5.0 KB
Line 
1//
2// PSMovieAlertController.m
3// Pester
4//
5// Created by Nicholas Riley on Sat Oct 26 2002.
6// Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import "PSAlarmAlertController.h"
10#import "PSMovieAlertController.h"
11#import "PSMovieAlert.h"
12#import "NSMovie-NJRExtensions.h"
13#import "NJRSoundManager.h"
14#import <QuickTime/Movies.h>
15
16@implementation PSMovieAlertController
17
18+ (PSMovieAlertController *)controllerWithAlarm:(PSAlarm *)anAlarm movieAlert:(PSMovieAlert *)anAlert;
19{
20 return [[self alloc] initWithAlarm: anAlarm movieAlert: anAlert];
21}
22
23- (void)close;
24{
25 [super close];
26 [NJRSoundManager restoreSavedDefaultOutputVolumeIfCurrently: [alert outputVolume]];
27}
28
29- (void)play;
30{
31 NSTimeInterval delay;
32 if (repetitions == 0) return;
33 if (IsMovieDone((Movie)theMovie) || repetitionsRemaining == repetitions) {
34 if (repetitionsRemaining == 0) {
35 [self close];
36 return;
37 }
38 repetitionsRemaining--;
39 [movieView gotoBeginning: self];
40 [movieView start: self];
41 }
42 delay = (GetMovieDuration((Movie)theMovie) - GetMovieTime((Movie)theMovie, NULL)) / (double)GetMovieTimeScale((Movie)theMovie);
43 // XXX should use a timebase callback for this instead (see NJRQTMediaPopUpButton); also, use QuickTimeÕs built-in loop functionality instead of rolling our own?
44 [self performSelector: @selector(play) withObject: nil afterDelay: delay inModes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
45}
46
47- (id)initWithAlarm:(PSAlarm *)anAlarm movieAlert:(PSMovieAlert *)anAlert;
48{
49 if ([self initWithWindowNibName: @"Movie alert"]) {
50 NSMovie *movie = [anAlert movie];
51 NSWindow *window = [self window]; // connect outlets
52 alarm = anAlarm;
53 alert = anAlert;
54 [movieView setMovie: movie];
55 theMovie = [movie QTMovie];
56 if ([alert hasVideo]) {
57 NSRect screenRect = [[window screen] visibleFrame];
58 float magnification = 1.0;
59 NSSize movieSize;
60 NSSize minSize = [window minSize];
61 float windowFrameHeight = [window frame].size.height - [[window contentView] frame].size.height;
62 NSRect frame;
63 screenRect.size.height -= windowFrameHeight;
64 minSize.height -= windowFrameHeight;
65 while (1) {
66 movieSize = [movieView sizeForMagnification: magnification];
67 movieSize.height -= 16; // controller is hidden, but its size is included (documented, ergh)
68 if (movieSize.width > screenRect.size.width || movieSize.height > screenRect.size.height)
69 magnification /= 2;
70 else
71 break;
72 }
73 if (movieSize.width < minSize.width) movieSize.width = minSize.width;
74 if (movieSize.height < minSize.height) movieSize.width = minSize.height;
75 [window setContentSize: movieSize];
76 [window center];
77 frame = [window frame];
78 frame.origin.y -= 400; // appear below notifier window - XXX this is very inaccurate, fix
79 if (frame.origin.y < screenRect.origin.y) frame.origin.y = screenRect.origin.y;
80 [window setFrame: frame display: NO];
81 [window setTitle: [alarm message]];
82 { // XXX workaround for (IMO) ugly appearance of Cocoa utility windows
83 NSView *miniButton = [window standardWindowButton: NSWindowMiniaturizeButton],
84 *zoomButton = [window standardWindowButton: NSWindowZoomButton];
85 // NOTE: this will not work if the window is resizable: when the frame is reset, the standard buttons reappear
86 [miniButton setFrameOrigin: NSMakePoint(-100, -100)];
87 [zoomButton setFrameOrigin: NSMakePoint(-100, -100)];
88 [[miniButton superview] setNeedsDisplay: YES];
89 [[zoomButton superview] setNeedsDisplay: YES];
90 }
91 [[self window] orderFrontRegardless];
92 }
93 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(close) name: PSAlarmAlertStopNotification object: nil];
94 repetitions = [alert repetitions];
95 repetitionsRemaining = repetitions;
96 if ([movie hasAudio] && [NJRSoundManager volumeIsNotMutedOrInvalid: [alert outputVolume]] && [NJRSoundManager saveDefaultOutputVolume]) {
97 [NJRSoundManager setDefaultOutputVolume: [alert outputVolume]];
98 }
99 if (![movie isStatic]) [self play]; // if it's an image, don't close the window automatically
100 }
101 return self;
102}
103
104- (void)dealloc;
105{
106 [[NSNotificationCenter defaultCenter] removeObserver: self];
107 [super dealloc];
108}
109
110@end
111
112@implementation PSMovieAlertController (NSWindowNotifications)
113
114- (void)windowWillClose:(NSNotification *)notification;
115{
116 repetitions = 0;
117 [movieView stop: self];
118 [alert completedForAlarm: alarm];
119 [self autorelease];
120 // note: there may still be a retained copy of this object until the runloop timer has let go of us at the end of the current movie playback cycle; donÕt worry about it.
121}
122
123@end
Note: See TracBrowser for help on using the repository browser.