Monday, 15 September 2014

iOS / iPhone - Silent switch not working after adding AVCaptureAudioDataOutput to AVCaptureSession -



iOS / iPhone - Silent switch not working after adding AVCaptureAudioDataOutput to AVCaptureSession -

i have avcapturesession manages video , image capture application. have sound effects in application of course of study silenced when user switches quiet switch on iphone.

however when add together avcaptureaudiodataoutput session, sound effects no longer silenced when quiet switch set.

here code used adding audion:

nserror *erroraud; avcapturedevice *audiodevice = [avcapturedevice defaultdevicewithmediatype:avmediatypeaudio]; avcapturedeviceinput *audiodeviceinput = [avcapturedeviceinput deviceinputwithdevice:audiodevice error:&erroraud]; if (erroraud) { nslog(@"%@", [erroraud localizeddescription]); } if ( [avsession canaddinput:audiodeviceinput] ) { [avsession addinput:audiodeviceinput]; [self setaudiocapturedeviceinput:audiodeviceinput]; } audiooutput = [[avcaptureaudiodataoutput alloc] init]; [audiooutput setsamplebufferdelegate:self queue:vsessionqueue]; if ([avsession canaddoutput:audiooutput]) { [avsession addoutput:audiooutput]; } (avcaptureconnection *connection in [audiooutput connections]) { (avcaptureinputport *port in [connection inputports]) { if ([[port mediatype] isequal:avmediatypeaudio]) { audioconnection = connection; break; } } } avauthorizationstatus audioauthorizationstatus = [avcapturedevice authorizationstatusformediatype:avmediatypeaudio]; //this sort of fixes silent mode issue makes capture session //stop outputs stop calling didoutputsamplebuffer //whenever sound effect played //avsession.usesapplicationaudiosession = no; //avsession.automaticallyconfiguresapplicationaudiosession = no;

as can above, tried messing usesapplicationaudiosession , automaticallyconfiguresapplicationaudiosession setting usesapplicationaudiosession = no makes capturesession stop calling

- (void)captureoutput:(avcaptureoutput *)captureoutput didoutputsamplebuffer:(cmsamplebufferref)samplebuffer fromconnection:(avcaptureconnection *)connection

whenever play sound effect using avaudioplayer

ios iphone audio avcapturesession silent

No comments:

Post a Comment