0

J'utilise Fedora 28. J'essaie d'exécuter ce code

 à partir de PyQt5.QtCore import QCoreApplication, QUrl
à partir de PyQt5.QtMultimedia importer QMediaContent, QMediaPlayer
à partir de PyQt5.QtWidgets import QApplication
importer sys
importer os


def handle_state_change (état):
    si état == QMediaPlayer.LoadingMedia:
        imprimer ('chargement')
    si état == QMediaPlayer.LoadedMedia:
        imprimer (chargement terminé)
        player.play ()
    if state == QMediaPlayer.EndOfMedia:
        imprimer ('jouer fini')
        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 (contenu)

app.exec ()

Cependant, il lance cette erreur

 Got keys from plugin meta data ("gstreamermediaplayer")
QFactoryLoader :: QFactoryLoader () vérifiant le chemin du répertoire "/ home / ziggs / PycharmProjects / mozart / venv / bin / mediaservice" ...
Impossible de charger la bibliothèque /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 ' introuvable (requis par /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so))
QLibraryPrivate :: loadPlugin a échoué sur "/home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so": "Impossible de charger la bibliothèque / home / ziggs / PycharmProjects / mozart / venv / lib / python3.6 / paquets-de-site / PyQt5 / Qt / plugins / mediaservice / libgstmediaplayer.so: (/lib64/libQt5MultimediaGstTools.so.5: la version `Qt_5_PRIVATE_API 'est introuvable (requis par / home / ziggs / PycharmProjects / mozart / venv / lib / python3.6 / paquet-site / PyQt5 / Qt / plugins / mediaservice / libgstmediaplayer.so)) "
defaultServiceProvider :: requestService (): aucun service trouvé pour - "org.qt-project.qt.mediaplayer"

J'ai googlé l'erreur et essayé d'installer les plugins pertinents

 dnf liste qt5-qtmultimedia gstreamer-plugins-laid
Letzte Prüfung auf abgelaufene Metadaten: vor 0:45:12 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