MultimediaSession
Represents an active voice session within a conversation.
A MultimediaSession provides:
State via MultimediaSessionState -- current status, mute and hold state.
Operations via MultimediaSessionOperations -- join, leave, muteMicrophone, hold.
Reactive streams via MultimediaSessionFlows -- event, localParticipant, remoteParticipants.
Lifecycle
A session is created in MultimediaSessionStatus.Created status.
Call join to begin the audio connection (MultimediaSessionStatus.Connecting).
Once connected, status becomes MultimediaSessionStatus.Connected or MultimediaSessionStatus.Answered when a remote participant joins.
Call end (or leave) to terminate the session (MultimediaSessionStatus.Ended).
Observe lifecycle transitions via the event flow, which emits MultimediaSessionEvent instances.
See also
Samples
session.muteMicrophone()
session.unmuteMicrophone()
session.hold(true)
session.activate()
session.end()scope.launch {
session.event.collect { event ->
when (event) {
is MultimediaSessionEvent.Connection.Connected -> {
// Call connected successfully
}
is MultimediaSessionEvent.Connection.Reconnecting -> {
// Network interruption, attempting to reconnect
}
is MultimediaSessionEvent.Connection.Disconnected -> {
// Call ended or lost connection
}
is MultimediaSessionEvent.ParticipantChanged -> {
// Agent joined or participant state changed
}
is MultimediaSessionEvent.Error -> {
val errorCode = event.code
}
else -> {}
}
}
}Properties
The unique identifier of the conversation this session belongs to.
The display name for this session, shown in notifications and the telecom framework.
A stream of MultimediaSessionEvent instances emitted during the session lifecycle.
A numeric identifier for this session, used internally for telecom framework integration.
Whether the microphone is currently muted.
Whether the speaker is currently muted.
A stream of the local MultimediaParticipant.
A stream of remote MultimediaParticipant instances currently in the session.
The current MultimediaSessionStatus of this session.
Functions
Enables or disables the microphone (audio input).
Enables or disables the speaker (audio output).
Places the session on hold. Equivalent to hold(onHold = true).
Mutes the microphone. Equivalent to audioInput(muteMicrophone = true).
Mutes the speaker. Equivalent to audioOutput(muteSpeaker = true).
Unmutes the microphone. Equivalent to audioInput(muteMicrophone = false).
Unmutes the speaker. Equivalent to audioOutput(muteSpeaker = false).