0

我正在尝试使用 QmediaPlayer 播放 .wav 文件,但是当我使用演示代码时,它不起作用,我听不到任何声音 这是演示代码

from PyQt5 import QtMultimedia
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication

app = QApplication(sys.argv)
file = QUrl.fromLocalFile(r'F:\Cloudmusic\test.mp3') # filepath
player=QtMultimedia.QMediaPlayer()
content = QtMultimedia.QMediaContent(file)
player.setMedia(content)
player.setVolume(50.0)
player.play()
sys.exit(app.exec_())

我的操作系统是 windows,并且没有收到错误消息

我在终端中运行它,并收到一些消息:

Warning: QT_DEVICE_PIXEL_RATIO is deprecated. Instead use:
   QT_AUTO_SCREEN_SCALE_FACTOR to enable platform plugin controlled per-screen factors.
   QT_SCREEN_SCALE_FACTORS to set per-screen DPI.
   QT_SCALE_FACTOR to set the application global scale factor.
libpng warning: iCCP: known incorrect sRGB profile
DirectShowPlayerService::doRender: Unknown error 0x80040266. 
4

0 回答 0