iDevGames Forums
i have bypassed mute settings of iphone (unwanted) - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: i have bypassed mute settings of iphone (unwanted) (/thread-9693.html)

i have bypassed mute settings of iphone (unwanted) - sefiroths - Jan 9, 2012 01:51 AM

i don't know what option i have used, i think it is related to this lines of code i have written because the sound exited from the auricolar and not from the audio amplifier:
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
        AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);    
        UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
        AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);

        NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
        NSDictionary *audioSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                       [NSNumber numberWithFloat: 44100.0],                 AVSampleRateKey,
                                       [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
                                       [NSNumber numberWithInt: 1],                         AVNumberOfChannelsKey,
                                       [NSNumber numberWithInt: AVAudioQualityMax],         AVEncoderAudioQualityKey,
        NSError *error;    
        bool b;
        recorder = [[AVAudioRecorder alloc] initWithURL:url settings:audioSettings error:&error];
        if (recorder) {
            b=[recorder prepareToRecord];
            NSLog(@"%@",(b ? @"OK" : @"NO"));
            recorder.meteringEnabled = YES;
            b=[recorder record];
            NSLog(@"%@", (b ? @"OK" : @"NO"));            
            //        NSLog(@"leveltimer");
            //        levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.03 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES];
        } else {
            NSLog(@"************** ERRORE: ****************");
            NSLog([error description]);    
        // Grab a reference to the AVAudioSession singleton
        audioSession = [AVAudioSession sharedInstance];
        soundCategory = AVAudioSessionCategoryAmbient;
        [audioSession setCategory:soundCategory error:&audioSessionError];
        // Now we have initialized the sound engine using ambient sound, we can check to see if ipod music is already playing.
        // If that is the case then you can leave the sound category as AmbientSound.  If ipod music is not playing we can set the
        // sound category to SoloAmbientSound so that decoding is done using the hardware.
        isExternalAudioPlaying = [self isExternalAudioPlaying];
        if (!isExternalAudioPlaying) {
            soundCategory =AVAudioSessionCategoryPlayAndRecord;// AVAudioSessionCategoryRecord;//AVAudioSessionCategorySoloAmbient;
            audioSessionError = nil;
            [audioSession setCategory:soundCategory error:&audioSessionError];
            if (audioSessionError)
                NSLog(@"WARNING - SoundManager: Error setting the sound category to SoloAmbientSound");
        AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);

how can i reenable mute settings/switch?

RE: i have bypassed mute settings of iphone (unwanted) - OneSadCookie - Jan 9, 2012 10:20 AM

MediaPlayback ignores the mute switch. From memory, BackgroundAudio is the right one?

RE: i have bypassed mute settings of iphone (unwanted) - sefiroths - Jan 25, 2012 03:16 AM

so i must change kAudioSessionCategory_MediaPlayback to kAudioSessionCategory_BackgroundAudio or something like that?
i'll try tonight