livekit / client-sdk-android

LiveKit SDK for Android
https://docs.livekit.io
Apache License 2.0
160 stars 63 forks source link

Issue muting local track publications #439

Closed daveleroy closed 3 days ago

daveleroy commented 2 weeks ago

How is one supposed to go about muting a local track publication?

I have tried the following but get the error Cannot assign to 'muted': the setter is internal in 'LocalTrackPublication'. The logic for muting the track appears to be in the setter of LocalTrackPublication but I guess I cannot call it because its marked internal in the base class?

val audio = room.localParticipant.getTrackPublication(Track.Source.MICROPHONE)
if (audio != null) {
    audio.muted = true
}

Is there another way to do this or is this a bug?

davidliu commented 3 days ago

For the usual case, if you enable the microphone through room.localParticipant.setMicrophoneEnabled(true), you can just use setMicrophoneEnabled(false).

Looks like the muted variable wasn't set to public for local tracks, will fix this.