79632024

Date: 2025-05-21 13:06:57
Score: 1
Natty:
Report link

@rushi-dave answer works.

However, the microphone is not muted. The solution to that is to add this:

private var localAudioTrack: AudioTrack? = null
override fun onTrack(transceiver: RtpTransceiver?) {
    val receiverTrack = transceiver?.receiver?.track()
    if (receiverTrack is AudioTrack) {
        remoteAudioTrack = receiverTrack
        remoteAudioTrack?.setEnabled(true)
        Napier.d(tag = TAG) { "Remote audio track: received and attached" }
    }

    val senderTrack = transceiver?.sender?.track()
    if (senderTrack is AudioTrack) {
        localAudioTrack = senderTrack
        localAudioTrack?.setEnabled(true)
        Napier.d(tag = TAG) { "Local audio track: received and attached" }
    }
}

Then we can enable either remoteAudioTrack (stream from AI) or localAudioTrack (microphone).

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @rushi-dave
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Sorry