Skip to content

Commit

Permalink
fix: hide volume button if no audio tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Aug 3, 2022
1 parent 92ccfd7 commit f4ce4cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gridplayer/widgets/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class VideoBlock(QWidget): # noqa: WPS230
info_change = pyqtSignal(str)
is_in_progress_change = pyqtSignal()
is_active_change = pyqtSignal(bool)
is_audio_present_change = pyqtSignal(bool)

def __init__(self, video_driver, context, **kwargs):
super().__init__(**kwargs)
Expand Down Expand Up @@ -276,6 +277,7 @@ def init_overlay(self):
(self.is_muted_change, overlay.set_is_muted),
(self.info_change, overlay.set_info_label),
(self.is_active_change, overlay.set_is_active),
(self.is_audio_present_change, overlay.set_volume_button_visible),
)

return overlay
Expand Down Expand Up @@ -792,6 +794,8 @@ def load_video_finish(self):
self.video_params.video_track_id = self.video_driver.cur_video_track_id
self.video_params.audio_track_id = self.video_driver.cur_audio_track_id

self.is_audio_present_change.emit(bool(self.audio_tracks))

self.video_status.hide()
self.show_overlay()

Expand Down
4 changes: 4 additions & 0 deletions gridplayer/widgets/video_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ def emit_volume_position(self, position):
def set_is_active(self, is_active):
self.border_widget.setVisible(is_active)

@pyqtSlot(bool)
def set_volume_button_visible(self, is_visible):
self.volume_button.setVisible(is_visible)

def _set_opacity(self, opacity):
effect = QGraphicsOpacityEffect(self)
effect.setOpacity(opacity)
Expand Down

0 comments on commit f4ce4cd

Please sign in to comment.