PDA

View Full Version : Determining playable media formats in qtmultimedia



janorcutt
24th March 2019, 12:21
Hi all,
I would like to write a function to determine which media formats can be played.
I thought about using QMediaPlayer::supportedMimeTypes, however the docs say this method is depreciated.
Is there any other way in qt or would i have to dig into kde frameworks/Windows Media apis for this.

Thanks in advance

anda_skoa
24th March 2019, 18:17
Looks like this was deprecated because it can depend on the output device.

See QAudioDeviceInfo::availableDevice() and QAudioDeviceInfo::supportedCodecs().

Haven't checked if there are similar classes for Video or how they are called.

Cheers,
_

P.S.: in lots of cases it can be helpful to check how a deprecated function is implemented. Often this gives hints on alternatives.
Doesn't fully help here since apparently the current implementation depends on non-public API
https://code.woboq.org/qt5/qtmultimedia/src/multimedia/playback/qmediaplayer.cpp.html#_ZN12QMediaPlayer18supported MimeTypesE6QFlagsINS_4FlagEE
and
https://code.woboq.org/qt5/qtmultimedia/src/multimedia/qmediaserviceprovider.cpp.html#525

janorcutt
24th March 2019, 18:44
Thanks for the reply.
QAudioDeviceInfo::supportedCodecs() returns only the pcm codec for some reason.
I could use QMimeDatabase but I'm unsure how well that works on Windows. Or macos for that matter.
Oh well more Google fu required

anda_skoa
25th March 2019, 07:17
In any case the QMediaPlayer::supportedMimeTypes() will at least continue to work until Qt6, at which point there is likely documentation what to port this call to.

Cheers,
_