2929
3030#import " OALAudioSession.h"
3131
32- #if __CC_PLATFORM_IOS || __CC_PLATFORM_MAC
33-
34- #import < AudioToolbox/AudioToolbox.h>
3532#import " ObjectALMacros.h"
3633#import " ARCSafe_MemMgmt.h"
3734#import " OALNotifications.h"
35+
36+ #if __CC_PLATFORM_IOS || __CC_PLATFORM_MAC
37+
38+ #import < AudioToolbox/AudioToolbox.h>
3839#import " IOSVersion.h"
3940
4041
@@ -777,8 +778,11 @@ - (void)inputIsAvailableChanged:(BOOL)isInputAvailable
777778
778779@end
779780
780- #else
781+ #endif /* __IPHONE_OS_VERSION_MAX_ALLOWED */
781782
783+ #elif __CC_PLATFORM_ANDROID // ANDROID
784+ #pragma mark Android OALAudioSession
785+ #import " CCDirector.h"
782786@implementation OALAudioSession
783787
784788#pragma mark Object Management
@@ -799,6 +803,10 @@ - (id) init
799803 honorSilentSwitch = NO ;
800804
801805 self.audioSessionActive = YES ;
806+ [[CCDirector sharedDirector ] addObserver: self
807+ forKeyPath: @" isPaused"
808+ options: (NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
809+ context: NULL ];
802810 }
803811 return self;
804812}
@@ -828,6 +836,19 @@ - (void) dealloc
828836
829837#pragma mark Suspend Handler
830838
839+ - (void )observeValueForKeyPath : (NSString *)keyPath
840+ ofObject : (id )object
841+ change : (NSDictionary *)change
842+ context : (void *)context {
843+ if ([keyPath isEqual: @" isPaused" ]) {
844+ if ([[CCDirector sharedDirector ] isPaused ]) {
845+ [self setManuallySuspended: YES ];
846+ } else {
847+ [self setManuallySuspended: NO ];
848+ }
849+ }
850+ }
851+
831852- (void ) addSuspendListener : (id <OALSuspendListener>) listener
832853{
833854 [suspendHandler addSuspendListener: listener];
@@ -885,6 +906,4 @@ - (void) forceEndInterruption
885906
886907@end
887908
888- #endif
889-
890- #endif // __CC_PLATFORM_IOS/MAC
909+ #endif /* __CC_PLATFORM_IOS/MAC/ANDROID */
0 commit comments