source: trunk/Cocoa/Pester/Source/PSMovieAlertController.m@ 40

Last change on this file since 40 was 40, checked in by Nicholas Riley, 21 years ago

PSDockBounceAlert: Make it work, assuming the app doesn't get brought
forward immediately upon the alarm activation.

NJRQTMediaPopUpButton: Fixed drag and drop. Added _descriptionForDraggingInfo:
to

PSMovieAlertController: Fixed movie vertical size, looks like a bug
got enshrined in the documentation.

PSAlarmAlertController: Don't force app to front until alerts are ready.

File size: 3.3 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 <QuickTime/Movies.h>
13
14@implementation PSMovieAlertController
15
16+ (PSMovieAlertController *)controllerWithAlarm:(PSAlarm *)alarm movieAlert:(PSMovieAlert *)alert;
17{
18 return [[self alloc] initWithAlarm: alarm movieAlert: alert];
19}
20
21- (void)play;
22{
23 NSTimeInterval delay;
24 if (repetitions == 0) return;
25 if (IsMovieDone((Movie)theMovie) || repetitionsRemaining == repetitions) {
26 if (repetitionsRemaining == 0) {
27 [self close];
28 return;
29 }
30 repetitionsRemaining--;
31 [movieView gotoBeginning: self];
32 [movieView start: self];
33 }
34 delay = (GetMovieDuration((Movie)theMovie) - GetMovieTime((Movie)theMovie, NULL)) / (double)GetMovieTimeScale((Movie)theMovie);
35 [self performSelector: @selector(play) withObject: nil afterDelay: delay inModes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
36}
37
38- (id)initWithAlarm:(PSAlarm *)alarm movieAlert:(PSMovieAlert *)alert;
39{
40 if ([self initWithWindowNibName: @"Movie alert"]) {
41 NSMovie *movie = [alert movie];
42 NSWindow *window = [self window]; // connect outlets
43 [movieView setMovie: movie];
44 theMovie = [movie QTMovie];
45 if ([alert hasVideo]) {
46 NSRect screenRect = [[window screen] visibleFrame];
47 float magnification = 1.0;
48 NSSize movieSize;
49 NSRect frame;
50 screenRect.size.height -= [window frame].size.height - [[window contentView] frame].size.height; // account for height of window frame
51 while (1) {
52 movieSize = [movieView sizeForMagnification: magnification];
53 movieSize.height -= 16; // controller is hidden, but its size is included (documented, ergh)
54 if (movieSize.width > screenRect.size.width || movieSize.height > screenRect.size.height)
55 magnification /= 2;
56 else
57 break;
58 }
59 [window setContentSize: movieSize];
60 [window center];
61 frame = [window frame];
62 frame.origin.y -= 250; // appear below notifier window
63 if (frame.origin.y < screenRect.origin.y) frame.origin.y = screenRect.origin.y;
64 [window setFrame: frame display: NO];
65 [window setTitle: [alarm message]];
66 [[self window] orderFrontRegardless];
67 }
68 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(close) name: PSAlarmAlertStopNotification object: nil];
69 repetitions = [alert repetitions];
70 repetitionsRemaining = repetitions;
71 [self play];
72 }
73 return self;
74}
75
76- (void)dealloc;
77{
78 [[NSNotificationCenter defaultCenter] removeObserver: self];
79 [super dealloc];
80}
81
82@end
83
84@implementation PSMovieAlertController (NSWindowNotifications)
85
86- (void)windowWillClose:(NSNotification *)notification;
87{
88 repetitions = 0;
89 [movieView stop: self];
90 [self release];
91 // 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.
92}
93
94@end
Note: See TracBrowser for help on using the repository browser.