Mercurial > libervia-web
changeset 1565:d282dbdd5ffd
browser (calls): restore UI state on reset:
`on_reset` is now called when webRTC reset happens (notably when a call ends). The UI
state is reset, in particular mute buttons so they don't appear in the wrong state during
the next call.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 21 Aug 2023 15:23:22 +0200 |
parents | bd3c880f4a47 |
children | e65d2ef1ded4 |
files | libervia/web/pages/calls/_browser/__init__.py libervia/web/pages/calls/_browser/webrtc.py |
diffstat | 2 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/web/pages/calls/_browser/__init__.py Fri Aug 18 17:43:01 2023 +0200 +++ b/libervia/web/pages/calls/_browser/__init__.py Mon Aug 21 15:23:22 2023 +0200 @@ -40,6 +40,7 @@ on_reconnect_cb=self.on_reconnect, on_connection_lost_cb=self.on_connection_lost, on_video_devices=self.on_video_devices, + on_reset_cb=self.on_reset_cb, ) self.mode = "search" self._status = None @@ -319,6 +320,14 @@ else: switch_camera_col_elt.classList.add("is-hidden") + def on_reset_cb(self) -> None: + """Call when webRTC connection is reset, we reset buttons statuses""" + document["full_screen_btn"].classList.remove("is-hidden") + document["exit_full_screen_btn"].classList.add("is-hidden") + for btn_elt in document["mute_audio_btn"], document["mute_video_btn"]: + btn_elt.classList.remove(INACTIVE_CLASS, MUTED_CLASS, "is-warning") + btn_elt.classList.add("is-success") + async def make_call(self, audio: bool = True, video: bool = True) -> None: """Start a WebRTC call
--- a/libervia/web/pages/calls/_browser/webrtc.py Fri Aug 18 17:43:01 2023 +0200 +++ b/libervia/web/pages/calls/_browser/webrtc.py Mon Aug 21 15:23:22 2023 +0200 @@ -22,7 +22,10 @@ on_reconnect_cb=None, on_connection_lost_cb=None, on_video_devices=None, + on_reset_cb=None, ): + # reset + self.on_reset_cb = on_reset_cb self.reset_instance() # ICE events @@ -81,6 +84,8 @@ } self.media_candidates = {} self.candidates_gathered = aio.Future() + if self.on_reset_cb is not None: + self.on_reset_cb() async def _populate_video_devices(self): devices = await window.navigator.mediaDevices.enumerateDevices()