[PyQt] Playing an ogg file with QtMultimedia?
Brandon Keith Biggs
brandonkeithbiggs at gmail.com
Fri Sep 4 07:56:33 BST 2015
Hello,
How does one go about playing a .ogg file? I have not managed to figure
out how to play a sound using the QtMultimedia module yet.
I have tried:
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5 import QtMultimedia
from PyQt5.QtCore import QUrl
class Window(QWidget):
def __init__(self):
super().__init__()
#These are what I have tried:
self.sound = QtMultimedia.QSoundEffect("sounds/my_sound.ogg", self)
self.sound = QtMultimedia.QAudio('sounds/my_sound.ogg'
self.sound =
QtMultimedia.QSoundEffect(QtMultimedia.QMediaResource('sounds/my_sound.ogg'),
self)
self.sound = QtMultimedia.QAudio(source="sounds/my_sound.ogg")
self.sound =
QtMultimedia.QSoundEffect(source=QUrl("sounds/my_sound.ogg"))
self.show()
But nothing seems to work. There doesn't seem to be any clear
documentation that I can find, so I am wondering if anyone can point me
in the right direction? I have pored over the C++ API,
<http://doc.qt.io/qt-5/qml-qtmultimedia-audio.html>but I can hardly make
heads or tails of what it is trying to say.
I don't think I am understanding how to load a QtResource.
Thank you,
--
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150904/1fa90b92/attachment.html>
More information about the PyQt
mailing list