video_player: apply loudnorm audio filter on mpv init

Reads the _loudnorm flag (set by main_window from the DB setting)
and applies af=loudnorm when mpv is first initialized.
This commit is contained in:
pax 2026-04-11 23:22:30 -05:00
parent 73206994ec
commit 2e9b99e4b8

View File

@ -337,6 +337,7 @@ class VideoPlayer(QWidget):
self._stream_record_tmp: Path | None = None self._stream_record_tmp: Path | None = None
self._stream_record_target: Path | None = None self._stream_record_target: Path | None = None
self._seeked_during_record: bool = False self._seeked_during_record: bool = False
self._loudnorm: bool = False
def _ensure_mpv(self) -> mpvlib.MPV: def _ensure_mpv(self) -> mpvlib.MPV:
"""Set up mpv callbacks on first use. MPV instance is pre-created.""" """Set up mpv callbacks on first use. MPV instance is pre-created."""
@ -364,6 +365,9 @@ class VideoPlayer(QWidget):
# exists. The qproperty-letterboxColor setter is a no-op if mpv # exists. The qproperty-letterboxColor setter is a no-op if mpv
# hasn't been initialized yet, so we have to (re)apply on init. # hasn't been initialized yet, so we have to (re)apply on init.
self._apply_letterbox_color() self._apply_letterbox_color()
# Apply audio normalization if enabled in settings.
if self._loudnorm:
self._mpv.af = "loudnorm"
return self._mpv return self._mpv
# -- Public API (used by app.py for state sync) -- # -- Public API (used by app.py for state sync) --