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;
|
||||
// whether background music is paused
|
||||
BOOL paused;
|
||||
BOOL stopped;
|
||||
@public
|
||||
BOOL systemPaused;//Used for auto resign handling
|
||||
NSTimeInterval systemPauseLocation;//Used for auto resign handling
|
||||
|
|
|
@ -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,8 +121,10 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
|||
}
|
||||
|
||||
-(void) resume {
|
||||
self->paused = NO;
|
||||
[audioSourcePlayer play];
|
||||
if (!stopped) {
|
||||
self->paused = NO;
|
||||
[audioSourcePlayer play];
|
||||
}
|
||||
}
|
||||
|
||||
-(BOOL) isPlaying {
|
||||
|
|
|
@ -119,7 +119,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
|||
|
||||
-(void) resume {
|
||||
self->paused = NO;
|
||||
[audioSourcePlayer play];
|
||||
[audioSourcePlayer resume];
|
||||
}
|
||||
|
||||
-(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. */
|
||||
- (void)pause; /* pauses playback, but remains ready to play. */
|
||||
- (void)stop; /* stops playback. no longer ready to play. */
|
||||
- (BOOL) resume;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue