Fedora
PyQt5 QMediaPlayer defaultServiceProvider::requestService(): no service found for - ‘org.qt-project.qt.mediaplayer’
我正在使用 Fedora 28。我正在嘗試執行此程式碼
from PyQt5.QtCore import QCoreApplication, QUrl from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer from PyQt5.QtWidgets import QApplication import sys import os def handle_state_change(state): if state == QMediaPlayer.LoadingMedia: print('loading') if state == QMediaPlayer.LoadedMedia: print('loading finished') player.play() if state == QMediaPlayer.EndOfMedia: print('playing finished') QCoreApplication.quit() app = QApplication(sys.argv) url = QUrl.fromLocalFile(os.path.abspath('./redalert.mp3')) content = QMediaContent(url) player = QMediaPlayer() player.mediaStatusChanged.connect(handle_state_change) player.setVolume(50) player.setMedia(content) app.exec()
但是,它會引發此錯誤
Got keys from plugin meta data ("gstreamermediaplayer") QFactoryLoader::QFactoryLoader() checking directory path "/home/ziggs/PycharmProjects/mozart/venv/bin/mediaservice" ... Cannot load library /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so: (/lib64/libQt5MultimediaGstTools.so.5: version `Qt_5_PRIVATE_API' not found (required by /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so)) QLibraryPrivate::loadPlugin failed on "/home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so" : "Cannot load library /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so: (/lib64/libQt5MultimediaGstTools.so.5: version `Qt_5_PRIVATE_API' not found (required by /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so))" defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
我已經用Google搜尋了錯誤並嘗試安裝相關外掛
dnf list qt5-qtmultimedia gstreamer-plugins-ugly Letzte Prüfung auf abgelaufene Metadaten: vor 0:45:12 am Mo 18 Jun 2018 21:42:00 CEST. Installierte Pakete gstreamer-plugins-ugly.x86_64 0.10.19-27.fc28 @rpmfusion-free qt5-qtmultimedia.x86_64 5.10.1-1.fc28 @anaconda Verfügbare Pakete gstreamer-plugins-ugly.i686 0.10.19-27.fc28 rpmfusion-free qt5-qtmultimedia.i686 5.10.1-1.fc28 fedora
我對 Qt5.10 有同樣的問題。
我必須回到 Qt5.8 才能讓它工作。