i have bypassed mute settings of iphone (unwanted)

Posts: 164
Joined: 2010.10
Post: #1
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?
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
MediaPlayback ignores the mute switch. From memory, BackgroundAudio is the right one?
Quote this message in a reply
Posts: 164
Joined: 2010.10
Post: #3
so i must change kAudioSessionCategory_MediaPlayback to kAudioSessionCategory_BackgroundAudio or something like that?
i'll try tonight
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  accelerometer settings baddapple 0 4,648 Apr 24, 2010 05:39 PM
Last Post: baddapple