<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
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.<br>
I have tried:<br>
import sys<br>
from PyQt5.QtWidgets import QApplication, QWidget<br>
from PyQt5 import QtMultimedia<br>
from PyQt5.QtCore import QUrl<br>
<br>
class Window(QWidget):<br>
def __init__(self):<br>
super().__init__()<br>
#These are what I have tried:<br>
self.sound =
QtMultimedia.QSoundEffect("sounds/my_sound.ogg", self)<br>
self.sound = QtMultimedia.QAudio('sounds/my_sound.ogg'<br>
self.sound =
QtMultimedia.QSoundEffect(QtMultimedia.QMediaResource('sounds/my_sound.ogg'),
self)<br>
self.sound =
QtMultimedia.QAudio(source="sounds/my_sound.ogg")<br>
self.sound =
QtMultimedia.QSoundEffect(source=QUrl("sounds/my_sound.ogg"))<br>
<br>
self.show()<br>
<br>
<br>
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 <a
href="http://doc.qt.io/qt-5/qml-qtmultimedia-audio.html">C++ API,
</a>but I can hardly make heads or tails of what it is trying to
say. <br>
I don't think I am understanding how to load a QtResource.<br>
Thank you,<br>
<br>
<div class="moz-signature">-- <br>
<a href="http://www.brandonkeithbiggs.com/">Brandon Keith Biggs</a></div>
</body>
</html>