-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.4.3, 6.5.0, 6.5.1
-
None
-
-
98d875475 (dev), ff263023f (6.5), a96ed9408 (6.6)
Steps to reproduce:
- Play attached wav file with multimedia\player example
- Note it stuttering compared to .mp3
Here is a simple example code which uses QMediaPlayer to play an audio file:
import sys
import timefrom PySide6.QtCore import QUrl, QCoreApplication
from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput
from PySide6.QtWidgets import QApplicationapp = QApplication(sys.argv)
#create a QMediaPlayer instance
player = QMediaPlayer()#set the URL of the audio file to play
url = QUrl.fromLocalFile(r"E:\PyCharmProjects\papagayo_clean\Tutorial Files\lame.wav")
url = QUrl.fromLocalFile(r"E:\PyCharmProjects\papagayo_clean\Tutorial Files\scared.wav")
player.setSource(url)
audio_output = QAudioOutput()
player.setAudioOutput(audio_output)
while not player.mediaStatus() in [QMediaPlayer.MediaStatus.LoadedMedia, QMediaPlayer.MediaStatus.BufferedMedia,
QMediaPlayer.MediaStatus.BufferingMedia]:
print(player.mediaStatus())
QCoreApplication.processEvents()
time.sleep(0.1)#play the audio file
print(player.mediaStatus())
print("Playing: {}".format(url.toString()))
player.play()#connect to the stateChanged signal to exit the program when the audio has finished playing
player.playbackStateChanged.connect(lambda state:
QApplication.quit() if state != QMediaPlayer.PlaybackState.PlayingState else None)#start the application event loop
sys.exit(app.exec())
Attached are 2 files, for the same sound.
If you change the code so that the mp3 loads then it will play fine, but if you play the wav file then it will stutter.
- relates to
-
PYSIDE-2314 An error occurred when playing a specific file using QMediaPlayer.
-
- Closed
-