Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Cant use QSoundEffect
Forum Updated to NodeBB v4.3 + New Features

Cant use QSoundEffect

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 397 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Not0_0Parsa
    wrote on last edited by Not0_0Parsa
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Might be a silly question but did you check that the URL built is correct ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ndiasN Offline
        ndiasN Offline
        ndias
        wrote on last edited by
        #3

        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 pyside6

        Regards

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved