source: trunk/Cocoa/Pester/Source/PSMediaAlert.m@ 543

Last change on this file since 543 was 543, checked in by Nicholas Riley, 15 years ago

Minimally convert media playback to QTKit. Some direct QuickTime access still needs migrating.

File size: 1.9 KB
Line 
1//
2// PSMediaAlert.m
3// Pester
4//
5// Created by Nicholas Riley on Tue Apr 08 2003.
6// Copyright (c) 2003 Nicholas Riley. All rights reserved.
7//
8
9#import "PSMediaAlert.h"
10#import "NSDictionary-NJRExtensions.h"
11#import "NJRSoundManager.h"
12
13// property list keys
14static NSString * const PLAlertRepetitions = @"times"; // NSString
15static NSString * const PLAlertOutputVolume = @"volume"; // NSNumber
16
17static const float PSMediaAlertNoVolume = 0;
18
19@implementation PSMediaAlert
20
21#pragma mark initialize-release
22
23- (id)initWithRepetitions:(unsigned short)numReps;
24{
25 if ( (self = [super init]) != nil) {
26 // XXX not DRY, but can't think of a more sensible way
27 if (numReps < 1)
28 numReps = 1;
29 else if (numReps > 99)
30 numReps = 99;
31 repetitions = numReps;
32 }
33 return self;
34}
35
36#pragma mark accessing
37
38- (unsigned short)repetitions;
39{
40 return repetitions;
41}
42
43- (float)outputVolume;
44{
45 return outputVolume;
46}
47
48- (void)setOutputVolume:(float)volume;
49{
50 if ([NJRSoundManager volumeIsNotMutedOrInvalid: volume])
51 outputVolume = volume;
52 else
53 outputVolume = PSMediaAlertNoVolume;
54}
55
56#pragma mark property list serialization (Pester 1.1)
57
58- (NSDictionary *)propertyListRepresentation;
59{
60 NSMutableDictionary *plAlert = [[super propertyListRepresentation] mutableCopy];
61 [plAlert setObject: [NSNumber numberWithUnsignedShort: repetitions] forKey: PLAlertRepetitions];
62 if (outputVolume != PSMediaAlertNoVolume) {
63 [plAlert setObject: [NSNumber numberWithFloat: outputVolume] forKey: PLAlertOutputVolume];
64 }
65 return [plAlert autorelease];
66}
67
68- (id)initWithPropertyList:(NSDictionary *)dict;
69{
70 if ( (self = [self initWithRepetitions: [[dict objectForRequiredKey: PLAlertRepetitions] unsignedShortValue]]) != nil) {
71 [self setOutputVolume: [[dict objectForKey: PLAlertOutputVolume] floatValue]];
72 }
73 return self;
74}
75
76@end
Note: See TracBrowser for help on using the repository browser.