Wip audio

This commit is contained in:
2026-03-10 17:15:55 +01:00
parent 935dbf6253
commit 567901b205
2 changed files with 20 additions and 7 deletions

View File

@@ -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',

View File

@@ -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)