most-jelly-63861
07/21/2025, 11:19 AMtall-airline-16756
07/21/2025, 11:20 AMtall-airline-16756
07/21/2025, 11:20 AMimport { AudioSession } from '@livekit/react-native;
// Configure audio to use earpiece by default
await AudioSession.configureAudio({
ios: {
defaultOutput: 'earpiece'
}
});
// Then connect to your room
await room.connect(url, token);
Make sure to call this configuration before connecting to the room for it to take effect.
Alternatively, you can use the useIOSAudioManagement hook and set preferSpeakerOutput to false to prefer earpiece output.
Let me know if you need further details on implementing this in your specific setup.
Sources: docs/classes/AudioSession.htmlmost-jelly-63861
07/21/2025, 11:22 AMtall-airline-16756
07/21/2025, 11:23 AMimport LiveKit
// Set earpiece as preferred output
audioManager.shared.isSpeakerOutputPreferred = false
This neat little trick will make sure your audio plays through the earpiece when no external devices are plugged in. Easy, right?
Oh, and here's another cool option if you prefer:
import LiveKit
// Use the predefined receiver configuration
AudioManager.shared.sessionConfiguration = .playAndRecordReceiver
Pro tip: Just make sure to set these up before you connect to a room, and you'll be all set!
Got any questions or a specific scenario you're working with? I'm all ears and happy to help you figure it out!
Sources: Sources/LiveKit/Types/AudioSessionConfiguration.swift