diff --git a/src/UI/DocumentViews/MpvContainer.cc b/src/UI/DocumentViews/MpvContainer.cc index 2930a7d91b8681c4735e391341341b1ced7794a4..ddaebac6927aad7ff39702eae3cfccb7e6847faa 100644 --- a/src/UI/DocumentViews/MpvContainer.cc +++ b/src/UI/DocumentViews/MpvContainer.cc @@ -281,6 +281,7 @@ MpvContainer::mpvPause() noexcept void MpvContainer::mpvTogglePlayback() noexcept { + qDebug() << "MPV: Toggling the playback"; asyncCommand(AsyncCmdType::TogglePlayback, { "cycle", "pause", "up", nullptr }); } diff --git a/src/UI/DocumentViews/MpvControls.cc b/src/UI/DocumentViews/MpvControls.cc index a40a198888077ebb78b35366981fac6bf41aff23..375ca3f9bba8cc6999aa6c508e3a73447478f15a 100644 --- a/src/UI/DocumentViews/MpvControls.cc +++ b/src/UI/DocumentViews/MpvControls.cc @@ -2,7 +2,8 @@ #include "MpvContainer.hh" #include <QSlider> -#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QPushButton> using namespace Vivy; @@ -10,7 +11,9 @@ MpvControls::MpvControls(MpvContainer *passedContainer, QWidget *parent) noexcep : QWidget(parent) , mpv(passedContainer) { - auto *progressBar = new QSlider(this); + auto *progressBar = new QSlider(this); + auto *togglePlaybackButton = new QPushButton("Pause", this); // Be default MPV is paused + progressBar->setTracking(false); progressBar->setOrientation(Qt::Horizontal); @@ -33,7 +36,15 @@ MpvControls::MpvControls(MpvContainer *passedContainer, QWidget *parent) noexcep timePosition = value; }); - auto *centralLayout = new QVBoxLayout(this); - centralLayout->addWidget(progressBar); + connect(togglePlaybackButton, &QAbstractButton::clicked, mpv, &MpvContainer::mpvTogglePlayback); + connect(mpv, &MpvContainer::mpvPlaybackToggled, this, + [togglePlaybackButton](bool isPlay) noexcept -> void { + togglePlaybackButton->setText(isPlay ? QStringLiteral("Play") + : QStringLiteral("Pause")); + }); + + auto *centralLayout = new QHBoxLayout(this); + centralLayout->addWidget(togglePlaybackButton); + centralLayout->addWidget(progressBar, 1); setLayout(centralLayout); }