After reviewing the doc of https://doc.qt.io/qt-6/qmediaplayer.html I found I adopted an outdated way of using QMediaPlayer, after porting to the standard way advocating by the doc, I got Error.FormatError, so maybe I should back to Qt5(it is working) and wait for Qt 6.5 to solve the problem. from PySide6.QtCore import* from PySide6.QtGui import* from PySide6.QtWidgets import* from PySide6.QtMultimedia import*
import sys classMainWindow(QMainWindow): # def__init__(self, parent=None): super().__init__(parent) self.player =QMediaPlayer() self.player.errorOccurred.connect(lambdaerr:print(err)) self.audioOutput =QAudioOutput() self.player.setAudioOutput(self.audioOutput) self.player.setSource(QUrl('http://dict.youdao.com/dictvoice?audio={}&type=2'.format('good'))) # self.player.setSource(QUrl("https://files.51voa.cn/202211/millions-of-americans-will-not-vote-in-english-on-election-day.mp3")) self.audioOutput.setVolume(50) self.player.play() if __name__ =="__main__": app =QApplication(sys.argv) MainWindow =MainWindow() MainWindow.show() sys.exit(app.exec()) At 2022-11-07 17:21:14, "Zhao Lee" <redstone-c...@163.com> wrote: QMediaPlayer cannot play mp3 audio files, no sound,。 Tested with the latest PySide on win11 from PySide6.QtCore import* from PySide6.QtGui import* from PySide6.QtWidgets import* from PySide6.QtMultimedia import* import sys classMainWindow(QMainWindow): # def__init__(self, parent=None): super().__init__(parent) player =QMediaPlayer() # player.setSource(QUrl('http://dict.youdao.com/dictvoice?audio={}&type=2'.format('good'))) player.setSource(QUrl('https://files.51voa.cn/202211/millions-of-americans-will-not-vote-in-english-on-election-day.mp3')) player.play() if __name__ =="__main__": app =QApplication(sys.argv) MainWindow =MainWindow() MainWindow.show() sys.exit(app.exec())
_______________________________________________ PySide mailing list PySide@qt-project.org https://lists.qt-project.org/listinfo/pyside