Use native QMediaPlayer looping instead of manual restart
Fixes flashing/flickering on short looping videos by using QMediaPlayer.Loops.Infinite instead of manually seeking to 0 on EndOfMedia.
This commit is contained in:
parent
94405cfa85
commit
be56db1f47
@ -310,6 +310,7 @@ class VideoPlayer(QWidget):
|
|||||||
def play_file(self, path: str, info: str = "") -> None:
|
def play_file(self, path: str, info: str = "") -> None:
|
||||||
self._current_file = path
|
self._current_file = path
|
||||||
self._error_fired = False
|
self._error_fired = False
|
||||||
|
self._player.setLoops(QMediaPlayer.Loops.Infinite)
|
||||||
self._player.setSource(QUrl.fromLocalFile(path))
|
self._player.setSource(QUrl.fromLocalFile(path))
|
||||||
if self._autoplay:
|
if self._autoplay:
|
||||||
self._player.play()
|
self._player.play()
|
||||||
@ -360,10 +361,7 @@ class VideoPlayer(QWidget):
|
|||||||
self._play_btn.setText("Play")
|
self._play_btn.setText("Play")
|
||||||
|
|
||||||
def _on_media_status(self, status) -> None:
|
def _on_media_status(self, status) -> None:
|
||||||
# Manual loop: when video ends, restart it
|
pass # Looping handled by QMediaPlayer.Loops.Infinite
|
||||||
if status == QMediaPlayer.MediaStatus.EndOfMedia:
|
|
||||||
self._player.setPosition(0)
|
|
||||||
self._player.play()
|
|
||||||
|
|
||||||
def _on_error(self, error, msg: str = "") -> None:
|
def _on_error(self, error, msg: str = "") -> None:
|
||||||
if self._current_file and not self._error_fired:
|
if self._current_file and not self._error_fired:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user