From 567901b205c393ee9e95cccd3956a6f04b96ad58 Mon Sep 17 00:00:00 2001 From: Xarkam Date: Tue, 10 Mar 2026 17:15:55 +0100 Subject: [PATCH] Wip audio --- La Tanière Launcher.spec | 2 +- src/mainwindow.py | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/La Tanière Launcher.spec b/La Tanière Launcher.spec index 53ca5ad..9787180 100644 --- a/La Tanière Launcher.spec +++ b/La Tanière Launcher.spec @@ -33,7 +33,7 @@ a = Analysis( 'PySide6.QtLocation', # 'PySide6.QtMultimedia', 'PySide6.QtMultimediaWidgets', - 'PySide6.QtNetwork', + # 'PySide6.QtNetwork', # Dépendance à QtMultimedia 'PySide6.QtNetworkAuth', 'PySide6.QtNfc', 'PySide6.QtOpenGL', diff --git a/src/mainwindow.py b/src/mainwindow.py index a5d1ccd..dbca15c 100644 --- a/src/mainwindow.py +++ b/src/mainwindow.py @@ -3,7 +3,7 @@ import os import webbrowser from pathlib import Path from PySide6 import QtGui -from PySide6.QtCore import Qt, QPropertyAnimation, QEasingCurve, QUrl, QResource +from PySide6.QtCore import Qt, QPropertyAnimation, QEasingCurve, QResource, QFile, QBuffer, QByteArray, QIODevice from PySide6.QtGui import QFontDatabase, QFont, QColor from PySide6.QtUiTools import QUiLoader from PySide6.QtWidgets import QMainWindow, QApplication, QGraphicsDropShadowEffect @@ -14,13 +14,16 @@ from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput import resources as resources # This is generated from the .qrc file # noqa: F401 +# Remove this into final release +from fake_patch_notes import patch_note + if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): bundle_dir = Path(sys._MEIPASS) else: bundle_dir = Path(__file__).resolve().parent.parent -# Remove this into final release -from fake_patch_notes import patch_note +# charger le fichier rcc compilé +QResource.registerResource(f"{bundle_dir}/resources.py") NO_STAFF = True CURRENT = os.path.dirname(os.path.realpath(__file__)) @@ -54,9 +57,19 @@ class MainWindow(QMainWindow): self.audio_output = QAudioOutput() self.media_player.setAudioOutput(self.audio_output) - # USE RESOURCE - #file_path = os.path.join(f":/assets/the-beat-of-nature-122841.mp3") - self.media_player.setSource(QUrl.fromLocalFile(":/assets/the-beat-of-nature-122841.mp3")) + # Using mp3 in resource + mp3file = QFile(":/assets/the-beat-of-nature-122841.mp3") + mp3file.open(QFile.ReadOnly) + mp3data = mp3file.readAll() + mp3file.close() + + # buffer mémoire + mp3buffer = QBuffer() + mp3buffer.setData(QByteArray(mp3data)) + mp3buffer.open(QIODevice.ReadOnly) + self.mp3buffer = mp3buffer + + self.media_player.setSourceDevice(self.mp3buffer) # Optionnel : Définir la valeur initiale du slider (ici: 10%) self.ui.audio_volume_adjust.setValue(10)