closed #4562, fix audio resume bug after stop the music

This commit is contained in:
andyque 2014-03-27 10:43:57 +08:00
parent b0e315637a
commit 26a04b38f2
5 changed files with 18 additions and 5 deletions

View File

@ -100,6 +100,7 @@ typedef enum {
BOOL backgroundMusic;
// whether background music is paused
BOOL paused;
BOOL stopped;
@public
BOOL systemPaused;//Used for auto resign handling
NSTimeInterval systemPauseLocation;//Used for auto resign handling

View File

@ -48,6 +48,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
mute = NO;
enabled_ = YES;
paused = NO;
stopped = NO;
}
return self;
}
@ -96,6 +97,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
if (enabled_) {
self->systemPaused = NO;
self->paused = NO;
self->stopped = NO;
[audioSourcePlayer play];
} else {
CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled");
@ -104,6 +106,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
-(void) stop {
self->paused = NO;
self->stopped = YES;
[audioSourcePlayer stop];
}
@ -118,9 +121,11 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
}
-(void) resume {
if (!stopped) {
self->paused = NO;
[audioSourcePlayer play];
}
}
-(BOOL) isPlaying {
if (state != kLAS_Init) {

View File

@ -119,7 +119,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
-(void) resume {
self->paused = NO;
[audioSourcePlayer play];
[audioSourcePlayer resume];
}
-(BOOL) isPlaying {

View File

@ -96,6 +96,7 @@ extern OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *o
- (BOOL)playAtTime:(NSTimeInterval) time; /* play a sound some time in the future. time should be greater than deviceCurrentTime. */
- (void)pause; /* pauses playback, but remains ready to play. */
- (void)stop; /* stops playback. no longer ready to play. */
- (BOOL) resume;
/* properties */

View File

@ -90,6 +90,12 @@ OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *outData)
return result;
}
- (BOOL) resume{
BOOL result = [_player resume];
return result;
}
-(void) pause {
[_player pause];
}