Unsolved Cant use QSoundEffect
-
Hi I'm trying to write a program that if I click a button it will play a sound this is my code
from PySide6.QtCore import QUrl from PySide6.QtMultimedia import QSoundEffect from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton class MainWindow(QMainWindow): def __init__(self): super().__init__() # Create QSoundEffect instance self.effect = QSoundEffect() self.effect.setSource(QUrl.fromLocalFile("C:\\Windows\\Media\\windows ding.wav")) # Create button to play sound effect button = QPushButton('Play Sound Effect', self) button.clicked.connect(self.play_sound_effect) self.setCentralWidget(button) def play_sound_effect(self): # Play the sound effect self.effect.play() if __name__ == '__main__': app = QApplication([]) window = MainWindow() window.show() app.exec_()
but I'm getting this error
qt.multimedia.audiooutput: Failed to set up resampler
Im using python 3.11 and pyside6 -
Hi and welcome to devnet,
Might be a silly question but did you check that the URL built is correct ?
-
Hi @Not0_0Parsa :
I tested it on my side. I was having same error as you reported. The issue did not happen after I upgraded PySide from 6.4.1 to 6.4.3 version.I am using Windows 10 and Python 3.7 on my machine.
Can you try to upgrade on your side:
python.exe -m pip install --upgrade pyside6Regards