简体   繁体   中英

Unable to import mediaplayer module

I want to build a simple mp3 player with Qt5 but I've not had much luck importing the required modules. How do I import Qt5 MediaPlayer? It seems like it is not available in pyqt5.

Here is how I attempted to do the import

from PyQt5.QtMultimedia import QMediaPlayer
from PyQt5 import QtCore

the result

Traceback (most recent call last):
File "C:/Users/ncodes/SkyDrive/Codes/Python/Experiment/py3.py", line 1, in <module>
  from PyQt5.QtMultimedia import QMediaPlayer
ImportError: cannot import name QMediaPlayer

I do not understand why QMediaPlayer cannot be imported because I know Qt5 has QMediaPlayer in QtMultimedia module.

there is no QMediaPlayer in PyQt5.QtMultimedia of current PyQt5

you can test by the following code

>>>import PyQt5.QtMultimedia 
>>>'QMediaPlayer' in [n for n in dir(PyQt5.QtMultimedia)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM