iOS Question SetAudioSession - Crash app

Pendrush

Well-Known Member
Licensed User
Longtime User
When user click on PLAY in my app, app call

B4X:
- (void)setAudioSession {
   AVAudioSession *audioSession = [AVAudioSession sharedInstance];
   NSError *err = nil;
   BOOL success = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&err];
   if (success) {
     success = [audioSession setActive:YES error:&err];
   }
   if (!success)
     [NSException raise:@"" format:@"Error setting audio session: %@", err];
}


When user click on STOP app call

B4X:
- (void)setAudioSessionNo {
   AVAudioSession *audioSession = [AVAudioSession sharedInstance];
   NSError *err = nil;
   BOOL success = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&err];
   if (success) {
     success = [audioSession setActive:NO error:&err];
   }
   if (!success)
     [NSException raise:@"" format:@"Error setting audio session: %@", err]; ' <- line number 3641
}


Only difference between two codes is setActive:YES and setActive:NO


Crash log:
0 CoreFoundation 0x23cf2fea __exceptionPreprocess + 122 (NSException.m:162)
1 libobjc.A.dylib 0x320dec86 objc_exception_throw + 34 (objc-exception.mm:527)
2 CoreFoundation 0x23cf2f30 +[NSException raise:format:] + 108 (NSException.m:140)
3 MyAPP 0xcc74a -[b4i_papp setAudioSessionNo] + 330 (b4i_papp.m:3641)
4 CoreFoundation 0x23cf7660 __invoking___ + 64 (NSForwarding.s:693)
5 CoreFoundation 0x23c22488 -[NSInvocation invoke] + 296 (NSForwarding.m:2699)
6 MyApp 0xe21c8 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
7 MyApp 0xf52a4 -[B4INativeObject RunMethod::] + 160

line 3641 is [NSException raise"" format"Error setting audio session: %@", err];
in second code (setAudioSessionNo)

I'm unable to reproduce error, app crash on iOS 8.0.2 and iOS 8.3
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…