From 64560fabb290b9a67bde21e6d9c8357d27a35014 Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Sat, 24 Jan 2026 16:25:52 +0200 Subject: [PATCH] Replace pyglet with QtMultimedia for audio playback Removed pyglet dependency and migrated notification sound playback to use PySide6.QtMultimedia's QMediaPlayer and QAudioOutput. Updated workflow and requirements files to remove pyglet and ensure PySide6.QtMultimedia is included in build steps. --- .github/workflows/build-linux.yml | 3 +-- .github/workflows/build-macos.yml | 3 +-- .github/workflows/build-windows.yml | 3 +-- requirements.txt | 1 - src/gui/ytsage_gui_main.py | 16 ++++++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index bf7182f..845593a 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -107,11 +107,11 @@ jobs: "PySide6.QtCore", "PySide6.QtGui", "PySide6.QtWidgets", + "PySide6.QtMultimedia", "requests", "PIL", "packaging", "markdown", - "pyglet", "loguru", "setuptools", ], @@ -125,7 +125,6 @@ jobs: "PySide6.QtXml", "PySide6.QtSql", "PySide6.QtHelp", - "PySide6.QtMultimedia", "PySide6.QtQml", "PySide6.QtQuick", "PySide6.QtWebEngineCore", diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 5531531..9a578c5 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -92,11 +92,11 @@ jobs: "PySide6.QtCore", "PySide6.QtGui", "PySide6.QtWidgets", + "PySide6.QtMultimedia", "requests", "PIL", "packaging", "markdown", - "pyglet", "loguru", "setuptools", ], @@ -110,7 +110,6 @@ jobs: "PySide6.QtXml", "PySide6.QtSql", "PySide6.QtHelp", - "PySide6.QtMultimedia", "PySide6.QtQml", "PySide6.QtQuick", "PySide6.QtWebEngineCore", diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index b64a4b3..e7966da 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -85,11 +85,11 @@ jobs: Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtCore",' Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtGui",' Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtWidgets",' + Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtMultimedia",' Add-Content -Path "setup_cxfreeze.py" -Value ' "requests",' Add-Content -Path "setup_cxfreeze.py" -Value ' "PIL",' Add-Content -Path "setup_cxfreeze.py" -Value ' "packaging",' Add-Content -Path "setup_cxfreeze.py" -Value ' "markdown",' - Add-Content -Path "setup_cxfreeze.py" -Value ' "pyglet",' Add-Content -Path "setup_cxfreeze.py" -Value ' "loguru",' Add-Content -Path "setup_cxfreeze.py" -Value ' "setuptools",' Add-Content -Path "setup_cxfreeze.py" -Value " ]," @@ -103,7 +103,6 @@ jobs: Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtXml",' Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtSql",' Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtHelp",' - Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtMultimedia",' Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtQml",' Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtQuick",' Add-Content -Path "setup_cxfreeze.py" -Value ' "PySide6.QtWebEngineCore",' diff --git a/requirements.txt b/requirements.txt index e6aed9d..550f74e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,5 @@ requests>=2.32.5 pillow>=12.0.0 packaging>=25.0 markdown>=3.10 -pyglet>=2.1.11 loguru>=0.7.3 setuptools>=80.9.0 \ No newline at end of file diff --git a/src/gui/ytsage_gui_main.py b/src/gui/ytsage_gui_main.py index 82d8d94..be71532 100644 --- a/src/gui/ytsage_gui_main.py +++ b/src/gui/ytsage_gui_main.py @@ -5,11 +5,11 @@ import webbrowser from pathlib import Path import markdown -import pyglet import requests from packaging import version -from PySide6.QtCore import Q_ARG, QMetaObject, Qt, QTimer, Slot, QThread, Signal +from PySide6.QtCore import Q_ARG, QMetaObject, Qt, QTimer, Slot, QThread, Signal, QUrl from PySide6.QtGui import QIcon +from PySide6.QtMultimedia import QAudioOutput, QMediaPlayer from PySide6.QtWidgets import ( QApplication, QButtonGroup, @@ -154,6 +154,11 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin, AnalysisMixin): # Track if video analysis is completed self.analysis_completed = False + # Initialize audio player + self.player = QMediaPlayer() + self.audio_output = QAudioOutput() + self.player.setAudioOutput(self.audio_output) + self.init_ui() # Defer heavy start-up tasks to ensure UI renders immediately @@ -208,10 +213,9 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin, AnalysisMixin): logger.warning(f"Notification sound file not found at: {SOUND_PATH}") return - # Play the sound using pyglet - # no need for the thread, as .play() is async - sound = pyglet.media.load(str(SOUND_PATH), streaming=False) - sound.play() + # Play the sound using QtMultimedia + self.player.setSource(QUrl.fromLocalFile(str(SOUND_PATH))) + self.player.play() logger.debug("Notification sound played") except Exception as e: logger.exception(f"Error playing notification sound: {e}")