fix build errors
This commit is contained in:
parent
c97f1d0619
commit
093fc7e95b
4 changed files with 52 additions and 3 deletions
|
@ -150,7 +150,11 @@ namespace mpv {
|
||||||
// "QVariant::Type(obsolete), the return value should be interpreted
|
// "QVariant::Type(obsolete), the return value should be interpreted
|
||||||
// as QMetaType::Type."
|
// as QMetaType::Type."
|
||||||
// So a cast really seems to be needed to avoid warnings (urgh).
|
// So a cast really seems to be needed to avoid warnings (urgh).
|
||||||
|
#if QT_VERSION_MAJOR == 5
|
||||||
|
return v.type() == static_cast<int>(t);
|
||||||
|
#else
|
||||||
return v.typeId() == static_cast<int>(t);
|
return v.typeId() == static_cast<int>(t);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void set(mpv_node* dst, const QVariant& src) {
|
void set(mpv_node* dst, const QVariant& src) {
|
||||||
if (test_type(src, QMetaType::QString)) {
|
if (test_type(src, QMetaType::QString)) {
|
||||||
|
|
|
@ -174,12 +174,48 @@ void QtMultimediaBackend::setVolume(int volume) {
|
||||||
#else
|
#else
|
||||||
m_player->setVolume(volume);
|
m_player->setVolume(volume);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
emit volumeChanged(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMultimediaBackend::setPosition(int position) {
|
void QtMultimediaBackend::setPosition(int position) {
|
||||||
m_player->setPosition(convertSliderProgress(position));
|
m_player->setPosition(convertSliderProgress(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtMultimediaBackend::setFullscreen(bool fullscreen) {
|
||||||
|
Q_UNUSED(fullscreen)
|
||||||
|
// No extra work needed here.
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMultimediaBackend::setMuted(bool muted) {
|
||||||
|
// This backend audio class does not support muting on Qt 5, so we emulate
|
||||||
|
// muting by seting volume to 0;
|
||||||
|
if (muted) {
|
||||||
|
// Remember volume and mute.
|
||||||
|
#if QT_VERSION_MAJOR == 6
|
||||||
|
m_volume = convertToSliderVolume(m_player->audioOutput()->volume());
|
||||||
|
#else
|
||||||
|
m_volume = m_player->volume();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_VERSION_MAJOR == 6
|
||||||
|
m_player->audioOutput()->setVolume(convertSliderVolume(0));
|
||||||
|
#else
|
||||||
|
m_player->setVolume(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Unmute.
|
||||||
|
#if QT_VERSION_MAJOR == 6
|
||||||
|
m_player->audioOutput()->setVolume(convertSliderVolume(m_volume));
|
||||||
|
#else
|
||||||
|
m_player->setVolume(m_volume);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
emit mutedChanged(muted);
|
||||||
|
}
|
||||||
|
|
||||||
QUrl QtMultimediaBackend::url() const {
|
QUrl QtMultimediaBackend::url() const {
|
||||||
return
|
return
|
||||||
#if QT_VERSION_MAJOR == 6
|
#if QT_VERSION_MAJOR == 6
|
||||||
|
@ -246,3 +282,7 @@ void QtMultimediaBackend::onPlaybackStateChanged(QMediaPlayer::PLAYBACK_STATE st
|
||||||
void QtMultimediaBackend::onSeekableChanged(bool seekable) {
|
void QtMultimediaBackend::onSeekableChanged(bool seekable) {
|
||||||
emit seekableChanged(seekable);
|
emit seekableChanged(seekable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QtMultimediaBackend::convertToSliderVolume(float volume) const {
|
||||||
|
return volume * 100;
|
||||||
|
}
|
||||||
|
|
|
@ -38,9 +38,12 @@ class QtMultimediaBackend : public PlayerBackend {
|
||||||
virtual void playPause();
|
virtual void playPause();
|
||||||
virtual void pause();
|
virtual void pause();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
|
||||||
virtual void setPlaybackSpeed(int speed);
|
virtual void setPlaybackSpeed(int speed);
|
||||||
virtual void setVolume(int volume);
|
virtual void setVolume(int volume);
|
||||||
virtual void setPosition(int position);
|
virtual void setPosition(int position);
|
||||||
|
virtual void setFullscreen(bool fullscreen);
|
||||||
|
virtual void setMuted(bool muted);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onPlaybackRateChanged(qreal speed);
|
void onPlaybackRateChanged(qreal speed);
|
||||||
|
@ -54,6 +57,7 @@ class QtMultimediaBackend : public PlayerBackend {
|
||||||
void onSeekableChanged(bool seekable);
|
void onSeekableChanged(bool seekable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int convertToSliderVolume(float volume) const;
|
||||||
float convertSliderVolume(int slider_volume) const;
|
float convertSliderVolume(int slider_volume) const;
|
||||||
qint64 convertSliderProgress(int slider_progress) const;
|
qint64 convertSliderProgress(int slider_progress) const;
|
||||||
int convertToSliderProgress(qint64 player_progress) const;
|
int convertToSliderProgress(qint64 player_progress) const;
|
||||||
|
@ -71,6 +75,7 @@ class QtMultimediaBackend : public PlayerBackend {
|
||||||
|
|
||||||
QMediaPlayer* m_player;
|
QMediaPlayer* m_player;
|
||||||
QVideoWidget* m_video;
|
QVideoWidget* m_video;
|
||||||
|
int m_volume;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QTMULTIMEDIABACKEND_H
|
#endif // QTMULTIMEDIABACKEND_H
|
||||||
|
|
|
@ -17,14 +17,14 @@ void SettingsMediaPlayer::loadSettings() {
|
||||||
onBeginLoadSettings();
|
onBeginLoadSettings();
|
||||||
|
|
||||||
#if defined(ENABLE_MEDIAPLAYER_LIBMPV)
|
#if defined(ENABLE_MEDIAPLAYER_LIBMPV)
|
||||||
m_ui.m_txtBackend->setText(QSL("QtMultimedia"));
|
m_ui.m_txtBackend->setText(QSL("libmpv"));
|
||||||
m_ui.m_helpInfo->setHelpText(tr("You use modern libmpv-based media player backend with API version %1.")
|
m_ui.m_helpInfo->setHelpText(tr("You use modern libmpv-based media player backend with API version %1.")
|
||||||
.arg(mpv_client_api_version()),
|
.arg(mpv_client_api_version()),
|
||||||
false);
|
false);
|
||||||
#elif defined(ENABLE_MEDIAPLAYER_QTMULTIMEDIA)
|
#elif defined(ENABLE_MEDIAPLAYER_QTMULTIMEDIA)
|
||||||
m_ui.m_txtBackend->setText(QSL("libmpv"));
|
m_ui.m_txtBackend->setText(QSL("QtMultimedia"));
|
||||||
m_ui.m_helpInfo->setHelpText(tr("You use lightweight QtMultimedia-based media player backend. If some videos do not "
|
m_ui.m_helpInfo->setHelpText(tr("You use lightweight QtMultimedia-based media player backend. If some videos do not "
|
||||||
"play, then you likely need to install some codec pack."),
|
"play, then you likely need to install some codecs."),
|
||||||
false);
|
false);
|
||||||
#else
|
#else
|
||||||
m_ui.m_txtBackend->setText(tr("no backend installed"));
|
m_ui.m_txtBackend->setText(tr("no backend installed"));
|
||||||
|
|
Loading…
Add table
Reference in a new issue