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
|
||||
// as QMetaType::Type."
|
||||
// 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);
|
||||
#endif
|
||||
}
|
||||
void set(mpv_node* dst, const QVariant& src) {
|
||||
if (test_type(src, QMetaType::QString)) {
|
||||
|
|
|
@ -174,12 +174,48 @@ void QtMultimediaBackend::setVolume(int volume) {
|
|||
#else
|
||||
m_player->setVolume(volume);
|
||||
#endif
|
||||
|
||||
emit volumeChanged(volume);
|
||||
}
|
||||
|
||||
void QtMultimediaBackend::setPosition(int 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 {
|
||||
return
|
||||
#if QT_VERSION_MAJOR == 6
|
||||
|
@ -246,3 +282,7 @@ void QtMultimediaBackend::onPlaybackStateChanged(QMediaPlayer::PLAYBACK_STATE st
|
|||
void QtMultimediaBackend::onSeekableChanged(bool 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 pause();
|
||||
virtual void stop();
|
||||
|
||||
virtual void setPlaybackSpeed(int speed);
|
||||
virtual void setVolume(int volume);
|
||||
virtual void setPosition(int position);
|
||||
virtual void setFullscreen(bool fullscreen);
|
||||
virtual void setMuted(bool muted);
|
||||
|
||||
private slots:
|
||||
void onPlaybackRateChanged(qreal speed);
|
||||
|
@ -54,6 +57,7 @@ class QtMultimediaBackend : public PlayerBackend {
|
|||
void onSeekableChanged(bool seekable);
|
||||
|
||||
private:
|
||||
int convertToSliderVolume(float volume) const;
|
||||
float convertSliderVolume(int slider_volume) const;
|
||||
qint64 convertSliderProgress(int slider_progress) const;
|
||||
int convertToSliderProgress(qint64 player_progress) const;
|
||||
|
@ -71,6 +75,7 @@ class QtMultimediaBackend : public PlayerBackend {
|
|||
|
||||
QMediaPlayer* m_player;
|
||||
QVideoWidget* m_video;
|
||||
int m_volume;
|
||||
};
|
||||
|
||||
#endif // QTMULTIMEDIABACKEND_H
|
||||
|
|
|
@ -17,14 +17,14 @@ void SettingsMediaPlayer::loadSettings() {
|
|||
onBeginLoadSettings();
|
||||
|
||||
#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.")
|
||||
.arg(mpv_client_api_version()),
|
||||
false);
|
||||
#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 "
|
||||
"play, then you likely need to install some codec pack."),
|
||||
"play, then you likely need to install some codecs."),
|
||||
false);
|
||||
#else
|
||||
m_ui.m_txtBackend->setText(tr("no backend installed"));
|
||||
|
|
Loading…
Add table
Reference in a new issue