iosobjective-cbluetoothcore-bluetooth

Record Audio From wireless Headset and Play it Through Bluetooth speaker


Record audio from BT headset. After record, switch route and play through wireless BT speaker.

I have implemented but audio is recording and playing in same headset or speaker. How record and play viseversa? any solution?


Solution

  • hey @Rushi i think this code will help you for playing audio viseversa

        -(IBAction)RecordButtonPlayed:(id)sender
    {
        if(player.playing)
        {
            [player stop];
        }
    
        if (!recorder.recording)
        {
            [[AVAudioSession sharedInstance] setActive:YES error:NULL];
            [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:NULL];
    
             [_btnRecord setImage:[UIImage imageNamed:@"player-stop-outline-512.png"] forState:UIControlStateNormal];
            [recorder record];
        }
    
        else
        {
             [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:NULL];
    
             [_btnRecord setImage:[UIImage imageNamed:@"171.png"] forState:UIControlStateNormal];
             [recorder stop];
    
        }
    }