mirror of https://github.com/axmolengine/axmol.git
closed #4562, fix audio resume bug after stop the music
This commit is contained in:
parent
b0e315637a
commit
26a04b38f2
|
@ -100,6 +100,7 @@ typedef enum {
|
||||||
BOOL backgroundMusic;
|
BOOL backgroundMusic;
|
||||||
// whether background music is paused
|
// whether background music is paused
|
||||||
BOOL paused;
|
BOOL paused;
|
||||||
|
BOOL stopped;
|
||||||
@public
|
@public
|
||||||
BOOL systemPaused;//Used for auto resign handling
|
BOOL systemPaused;//Used for auto resign handling
|
||||||
NSTimeInterval systemPauseLocation;//Used for auto resign handling
|
NSTimeInterval systemPauseLocation;//Used for auto resign handling
|
||||||
|
|
|
@ -48,6 +48,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
||||||
mute = NO;
|
mute = NO;
|
||||||
enabled_ = YES;
|
enabled_ = YES;
|
||||||
paused = NO;
|
paused = NO;
|
||||||
|
stopped = NO;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +97,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
||||||
if (enabled_) {
|
if (enabled_) {
|
||||||
self->systemPaused = NO;
|
self->systemPaused = NO;
|
||||||
self->paused = NO;
|
self->paused = NO;
|
||||||
|
self->stopped = NO;
|
||||||
[audioSourcePlayer play];
|
[audioSourcePlayer play];
|
||||||
} else {
|
} else {
|
||||||
CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled");
|
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 {
|
-(void) stop {
|
||||||
self->paused = NO;
|
self->paused = NO;
|
||||||
|
self->stopped = YES;
|
||||||
[audioSourcePlayer stop];
|
[audioSourcePlayer stop];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,9 +121,11 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) resume {
|
-(void) resume {
|
||||||
|
if (!stopped) {
|
||||||
self->paused = NO;
|
self->paused = NO;
|
||||||
[audioSourcePlayer play];
|
[audioSourcePlayer play];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-(BOOL) isPlaying {
|
-(BOOL) isPlaying {
|
||||||
if (state != kLAS_Init) {
|
if (state != kLAS_Init) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
||||||
|
|
||||||
-(void) resume {
|
-(void) resume {
|
||||||
self->paused = NO;
|
self->paused = NO;
|
||||||
[audioSourcePlayer play];
|
[audioSourcePlayer resume];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) isPlaying {
|
-(BOOL) isPlaying {
|
||||||
|
|
|
@ -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. */
|
- (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)pause; /* pauses playback, but remains ready to play. */
|
||||||
- (void)stop; /* stops playback. no longer ready to play. */
|
- (void)stop; /* stops playback. no longer ready to play. */
|
||||||
|
- (BOOL) resume;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,12 @@ OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *outData)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) resume{
|
||||||
|
BOOL result = [_player resume];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void) pause {
|
-(void) pause {
|
||||||
[_player pause];
|
[_player pause];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue