Skip to content

Commit 8bdc4e8

Browse files
committed
ui: don't autoplay audio if player is muted
1 parent b939810 commit 8bdc4e8

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/tagstudio/qt/controllers/preview_thumb.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,16 @@ def _render_placeholder(self, filepath: Path) -> None:
363363
date_modified=self._date_modified,
364364
)
365365

366-
def _update_media_player(self, filepath: Path) -> None:
366+
def _update_media_player(self, filepath: Path, is_audio: bool) -> None:
367367
"""Display either audio or video."""
368-
self.layout().media_player.play(path_on_disk(filepath))
368+
self.layout().media_player.play(path_on_disk(filepath), is_audio=is_audio)
369369

370370
def _display_video(self, filepath: Path) -> None:
371371
"""Play a video, loading its stats in the background."""
372372
self._should_render_on_resize = False
373373

374374
self._switch_preview(_PreviewType.VIDEO)
375-
self._update_media_player(filepath)
375+
self._update_media_player(filepath, is_audio=False)
376376
self._render_pool.start(lambda: self._probe_video(filepath))
377377

378378
def _probe_video(self, filepath: Path) -> None:
@@ -394,7 +394,7 @@ def _display_audio(self, filepath: Path, is_new_file: bool, start_player: bool =
394394
self._render_placeholder(filepath)
395395
self._render_preview(filepath)
396396
if start_player:
397-
self._update_media_player(filepath)
397+
self._update_media_player(filepath, is_audio=True)
398398

399399
def _play_animation(self, data: bytes, size: tuple[int, int]) -> bool:
400400
"""Play an animated image, returning `False` if it's not actually animated."""

‎src/tagstudio/qt/mixed/media_player.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def stop(self) -> None:
386386
self.filepath = None
387387
self.player.setSource(QUrl())
388388

389-
def play(self, filepath: Path) -> None:
389+
def play(self, filepath: Path, is_audio: bool) -> None:
390390
"""Set the source of the QMediaPlayer and play."""
391391
self.filepath = filepath
392392
if not self.is_paused:
@@ -395,7 +395,7 @@ def play(self, filepath: Path) -> None:
395395
else:
396396
self.player.setSource(QUrl.fromLocalFile(self.filepath))
397397

398-
if self.autoplay.isChecked():
398+
if self.autoplay.isChecked() and not (is_audio and self.player.audioOutput().isMuted()):
399399
self.player.play()
400400

401401
def load_toggle_play_icon(self, playing: bool) -> None:

0 commit comments

Comments
 (0)