BTW this piece of code works fine on PyQt6.
------ Исходное сообщение ------
От "Zhao Lee" <redstone-c...@163.com>
Кому "pyside" <pyside@qt-project.org>
Дата 07.11.2022 11:57:42
Тема Re: [PySide] QMediaPlayer cannot play mp3 audio files
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())
_______________________________________________
PySide mailing list
PySide@qt-project.org
https://lists.qt-project.org/listinfo/pyside