video_player: annotate silent excepts
Four mpv-state transition guards (letterbox color apply, hwdec re-arm on play_file, hwdec drop on stop, replay-on-end seek) each gained a one-line comment naming the absorbed failure and the graceful fallback. No behavior change.
This commit is contained in:
parent
873dcd8998
commit
b63341fec1
@ -158,6 +158,9 @@ class VideoPlayer(QWidget):
|
|||||||
self._mpv['background'] = 'color'
|
self._mpv['background'] = 'color'
|
||||||
self._mpv['background-color'] = self._letterbox_color.name()
|
self._mpv['background-color'] = self._letterbox_color.name()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
# mpv not fully initialized or torn down; letterbox color
|
||||||
|
# is a cosmetic fallback so a property-write refusal just
|
||||||
|
# leaves the default black until next set.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __init__(self, parent: QWidget | None = None, embed_controls: bool = True) -> None:
|
def __init__(self, parent: QWidget | None = None, embed_controls: bool = True) -> None:
|
||||||
@ -440,6 +443,9 @@ class VideoPlayer(QWidget):
|
|||||||
try:
|
try:
|
||||||
m['hwdec'] = 'auto'
|
m['hwdec'] = 'auto'
|
||||||
except Exception:
|
except Exception:
|
||||||
|
# If hwdec re-arm is refused, mpv falls back to software
|
||||||
|
# decode silently — playback still works, just at higher
|
||||||
|
# CPU cost on this file.
|
||||||
pass
|
pass
|
||||||
self._current_file = path
|
self._current_file = path
|
||||||
self._media_ready_fired = False
|
self._media_ready_fired = False
|
||||||
@ -481,6 +487,9 @@ class VideoPlayer(QWidget):
|
|||||||
try:
|
try:
|
||||||
self._mpv['hwdec'] = 'no'
|
self._mpv['hwdec'] = 'no'
|
||||||
except Exception:
|
except Exception:
|
||||||
|
# Best-effort VRAM release on stop; if mpv is mid-
|
||||||
|
# teardown and rejects the write, GL context destruction
|
||||||
|
# still drops the surface pool eventually.
|
||||||
pass
|
pass
|
||||||
self._time_label.setText("0:00")
|
self._time_label.setText("0:00")
|
||||||
self._duration_label.setText("0:00")
|
self._duration_label.setText("0:00")
|
||||||
@ -527,6 +536,9 @@ class VideoPlayer(QWidget):
|
|||||||
if pos is not None and dur is not None and dur > 0 and pos >= dur - 0.5:
|
if pos is not None and dur is not None and dur > 0 and pos >= dur - 0.5:
|
||||||
self._mpv.command('seek', 0, 'absolute+exact')
|
self._mpv.command('seek', 0, 'absolute+exact')
|
||||||
except Exception:
|
except Exception:
|
||||||
|
# Replay-on-end is a UX nicety; if mpv refuses the
|
||||||
|
# seek (stream not ready, state mid-transition) just
|
||||||
|
# toggle pause without rewinding.
|
||||||
pass
|
pass
|
||||||
self._mpv.pause = not self._mpv.pause
|
self._mpv.pause = not self._mpv.pause
|
||||||
self._play_btn.setIcon(self._play_icon if self._mpv.pause else self._pause_icon)
|
self._play_btn.setIcon(self._play_icon if self._mpv.pause else self._pause_icon)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user