Skip to content

Commit

Permalink
Fix for jeertmans#293 and similar errors
Browse files Browse the repository at this point in the history
This commit fixes the screen going black after the video ends in versions of PySide6 v6.5.3 and newer. This allows for other errors (like jeertmans#315) that require a newer version of PySide6 to also be fixed.
  • Loading branch information
PeculiarProgrammer committed Aug 23, 2024
1 parent c3e1aa0 commit 517fbc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions manim_slides/present/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from qtpy.QtCore import Qt, QTimer, QUrl, Signal, Slot
from qtpy.QtGui import QCloseEvent, QIcon, QKeyEvent, QScreen
from qtpy.QtMultimedia import QAudioOutput, QMediaPlayer
from qtpy.QtMultimedia import QAudioOutput, QMediaPlayer, QVideoFrame
from qtpy.QtMultimediaWidgets import QVideoWidget
from qtpy.QtWidgets import (
QHBoxLayout,
Expand Down Expand Up @@ -240,6 +240,18 @@ def __init__(
self.presentation_changed.connect(self.presentation_changed_callback)
self.slide_changed.connect(self.slide_changed_callback)

old_frame = None

def frame_changed(frame: QVideoFrame) -> None:
nonlocal old_frame

if old_frame and (frame.size() != old_frame.size()):
self.video_sink.setVideoFrame(old_frame)
frame = old_frame

self.info.video_sink.setVideoFrame(frame)
old_frame = frame

self.info = Info(
full_screen=full_screen,
aspect_ratio_mode=aspect_ratio_mode,
Expand All @@ -248,7 +260,7 @@ def __init__(
self.info.close_event.connect(self.closeEvent)
self.info.key_press_event.connect(self.keyPressEvent)
self.video_sink.videoFrameChanged.connect(
lambda frame: self.info.video_sink.setVideoFrame(frame)
frame_changed
)
self.hide_info_window = hide_info_window

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ manim = ["manim>=0.18.0"]
manimgl = ["manimgl>=1.6.1;python_version<'3.12'"]
pyqt6 = ["pyqt6>=6.6.1"]
pyqt6-full = ["manim-slides[full,pyqt6]"]
pyside6 = ["pyside6>=6.5.1,<6.5.3;python_version<'3.12'", "pyside6>=6.6.1;python_version>='3.12'"]
pyside6 = ["pyside6>=6.6.1"]
pyside6-full = ["manim-slides[full,pyside6]"]
sphinx-directive = ["docutils>=0.20.1", "manim-slides[manim]"]
tests = [
Expand Down

0 comments on commit 517fbc6

Please sign in to comment.