author | Medo <smaxein@googlemail.com> |
Thu, 19 Jul 2012 18:58:18 +0200 | |
changeset 7342 | 0e29eec2df5c |
parent 6659 | a6030b32b222 |
child 8441 | a00b0fa0dbd7 |
permissions | -rw-r--r-- |
6656
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
1 |
// MXAudioPlayerFadeOperation.h |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
2 |
// |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
3 |
// Created by Andrew Mackenzie-Ross on 30/11/10. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
4 |
// mackross.net |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
5 |
// |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
6 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
7 |
#import <Foundation/Foundation.h> |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
8 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
9 |
@class AVAudioPlayer; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
10 |
@interface MXAudioPlayerFadeOperation : NSOperation { |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
11 |
AVAudioPlayer *_audioPlayer; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
12 |
NSTimeInterval _fadeDuration; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
13 |
NSTimeInterval _delay; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
14 |
float _finishVolume; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
15 |
BOOL _pauseAfterFade; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
16 |
BOOL _stopAfterFade; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
17 |
BOOL _playBeforeFade; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
18 |
} |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
19 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
20 |
// The AVAudioPlayer that the volume fade will be applied to. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
21 |
// Retained until the fade is completed. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
22 |
// Must be set with init method. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
23 |
@property (nonatomic, retain, readonly) AVAudioPlayer *audioPlayer; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
24 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
25 |
// The duration of the volume fade. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
26 |
// Default value is 1.0 |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
27 |
@property (nonatomic, assign) NSTimeInterval fadeDuration; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
28 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
29 |
// The delay before the volume fade begins. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
30 |
// Default value is 0.0 |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
31 |
@property (nonatomic, assign) NSTimeInterval delay; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
32 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
33 |
// The volume that will be faded to. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
34 |
// Default value is 0.0 |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
35 |
@property (nonatomic, assign) float finishVolume; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
36 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
37 |
// If YES, audio player will be sent a pause message when the fade has completed. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
38 |
// Default value is NO, however, if finishVolume is 0.0, default is YES |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
39 |
@property (nonatomic, assign) BOOL pauseAfterFade; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
40 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
41 |
// If YES, when the fade has completed the audio player will be sent a stop message. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
42 |
// Default value is NO. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
43 |
@property (nonatomic, assign) BOOL stopAfterFade; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
44 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
45 |
// If YES, audio player will be sent a play message after the delay. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
46 |
// Default value is YES. |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
47 |
@property (nonatomic, assign) BOOL playBeforeFade; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
48 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
49 |
// Init Methods |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
50 |
- (id)initFadeWithAudioPlayer:(AVAudioPlayer*)player toVolume:(float)volume overDuration:(NSTimeInterval)duration withDelay:(NSTimeInterval)timeDelay; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
51 |
- (id)initFadeWithAudioPlayer:(AVAudioPlayer*)player toVolume:(float)volume overDuration:(NSTimeInterval)duration; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
52 |
- (id)initFadeWithAudioPlayer:(AVAudioPlayer*)player toVolume:(float)volume; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
53 |
- (id)initFadeWithAudioPlayer:(AVAudioPlayer*)player; |
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
54 |
|
6aeaba3ee584
ios: added MXAudioPlayerFadeOperation to allow easy fade in and out of background music
koda
parents:
diff
changeset
|
55 |
@end |