configure, GUI: fix detection of & compilation with Qt multimedia ≥ 6.2.0

This commit is contained in:
Moritz Bunkus 2022-04-08 21:34:23 +02:00
parent 022ffc87cc
commit f0521d73c1
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
3 changed files with 26 additions and 1 deletions

View File

@ -86,6 +86,8 @@
saying only that prefixes "are suitable sequences" for use with the
variants. What is now verified, though, is that no variant is used multiple
times within the same language tag. Part of the implementation/fix of #3307.
* build system & MKVToolNix GUI: fixed detecting the presence of & the
compilation with the multimedia module of Qt version 6.2.0 and newer.
## Build system changes

View File

@ -90,7 +90,7 @@ EOT
"$QMAKE6" -makefile -nocache configure.pro > /dev/null
result2=$?
if test -z $qmake_qt_ui_try; then
if test $result2 = 0 -o -z $qmake_qt_ui_try; then
break
fi

View File

@ -3,6 +3,9 @@
#include <Qt>
#if HAVE_QMEDIAPLAYER
# if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
# include <QAudioOutput>
# endif
# include <QMediaPlayer>
#else // HAVE_QMEDIAPLAYER
@ -34,10 +37,17 @@ class MediaPlayerPrivate {
public:
std::unique_ptr<QMediaPlayer> player;
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
std::unique_ptr<QAudioOutput> audioOutput;
#endif
explicit MediaPlayerPrivate()
: player{new QMediaPlayer}
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
audioOutput.reset(new QAudioOutput);
player->setAudioOutput(audioOutput.get());
#endif
}
};
@ -53,7 +63,11 @@ MediaPlayer::~MediaPlayer() {
bool
MediaPlayer::isPlaying()
const {
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
return p_func()->player->playbackState() == QMediaPlayer::PlayingState;
#else
return p_func()->player->state() == QMediaPlayer::PlayingState;
#endif
}
void
@ -63,8 +77,13 @@ MediaPlayer::playFile(QString const &fileName,
stopPlayback();
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
p->audioOutput->setVolume(volume);
p->player->setSource(QUrl::fromLocalFile(fileName));
#else
p->player->setVolume(volume);
p->player->setMedia(QUrl::fromLocalFile(fileName));
#endif
p->player->play();
}
@ -73,7 +92,11 @@ MediaPlayer::stopPlayback() {
auto p = p_func();
p->player->stop();
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
p->player->setSource({});
#else
p->player->setMedia({});
#endif
}
}