Skip to content

Commit

Permalink
Support mute/unmute for local tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao committed Dec 4, 2024
1 parent 99f79c3 commit 28e64ef
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions livekit-rtc/livekit/rtc/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ def create_audio_track(name: str, source: "AudioSource") -> "LocalAudioTrack":
resp = FfiClient.instance.request(req)
return LocalAudioTrack(resp.create_audio_track.track)

def mute(self):
req = proto_ffi.FfiRequest()
req.local_track_mute.track_handle = self._ffi_handle.handle
req.local_track_mute.mute = True
FfiClient.instance.request(req)

def unmute(self):
req = proto_ffi.FfiRequest()
req.local_track_mute.track_handle = self._ffi_handle.handle
req.local_track_mute.mute = False
FfiClient.instance.request(req)

def __repr__(self) -> str:
return f"rtc.LocalAudioTrack(sid={self.sid}, name={self.name})"

Expand All @@ -97,6 +109,18 @@ def create_video_track(name: str, source: "VideoSource") -> "LocalVideoTrack":
resp = FfiClient.instance.request(req)
return LocalVideoTrack(resp.create_video_track.track)

def mute(self):
req = proto_ffi.FfiRequest()
req.local_track_mute.track_handle = self._ffi_handle.handle
req.local_track_mute.mute = True
FfiClient.instance.request(req)

def unmute(self):
req = proto_ffi.FfiRequest()
req.local_track_mute.track_handle = self._ffi_handle.handle
req.local_track_mute.mute = False
FfiClient.instance.request(req)

def __repr__(self) -> str:
return f"rtc.LocalVideoTrack(sid={self.sid}, name={self.name})"

Expand Down

0 comments on commit 28e64ef

Please sign in to comment.