python - Play a sound with QAudioOutput in PyQt -
my app should work both on windows , linux(ubuntu). have reimplement notification sounds, because qsound not work under ubuntu. trying qaudiooutput.
i can't run code, , don't understand have do. have tips? or perhaps idea works on both os?
from pyqt4.qtgui import qapplication import sys pyqt4.qtmultimedia import qaudiooutput, qaudioformat pyqt4.qtcore import qfile, qiodevice app=qapplication(sys.argv) #1st edit output=qaudiooutput() soundfile=qfile() soundfile.setfilename("c:\\users\\delete_2.wav") soundfile.open(qiodevice.readonly) output.start(soundfile) app.exec_() #1st edit
i don't know if it's issue, need create qapplication
object , start main event loop. add beginning of program:
app = qapplication()
add end of program:
app.exec_()
Comments
Post a Comment