Question

I was wondering if anyone has had any luck using QMediaPlayer in PyQt4?

>>> from PyQt4.QtMultimedia import QMediaPlayer

tells me:

ImportError: cannot import name QMediaPlayer

And it doesn't show up here either:

>>> dir(QtMultimedia)
['QAbstractVideoBuffer', 'QAbstractVideoSurface', 'QAudio', 'QAudioDeviceInfo', 'QAudioFormat', 'QAudioInput', 'QAudioOutput', 'QVideoFrame', 'QVideoSurfaceFormat', '__doc__', '__file__', '__name__', '__package__']

According to the docs (and various code snippets I've come across), it should be there. I'm using version 4.8.5 (Mac OS X 10.8.4).

(In my install of PyQt5, QMediaPlayer just works. However, I'm using pyinstaller to build the application and am not sure how well it handles PyQt5. In other words, I would prefer to continue using PyQt4 for this project if possible.)

Was it helpful?

Solution

The QMediaPlayer class is only available in Qt5, so obviously PyQt4 cannot support it:

It is possible to build PyQt4 against Qt5. However, it will only include the subset of classes common to both Qt4 and Qt5. Any classes added in Qt5 won't be included.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top