diff --git a/src/UI/DocumentViews/MpvContainer.cc b/src/UI/DocumentViews/MpvContainer.cc index fcc6d076ab2ae1cb643ae84ad99015f35eb47296..1d87e892ea5a9b6df700abe539c40a479a9c41a3 100644 --- a/src/UI/DocumentViews/MpvContainer.cc +++ b/src/UI/DocumentViews/MpvContainer.cc @@ -60,6 +60,7 @@ void MpvContainer::closeMpv() noexcept { if (mpv) { + qDebug() << "Closing the MPV context"; registerMpvTimeCallback(nullptr); registerMpvDurationCallback(nullptr); mpv_handle *tmp_mpv = mpv; diff --git a/src/UI/DocumentViews/MpvControls.cc b/src/UI/DocumentViews/MpvControls.cc index 571513896756944fc756f0c237477d687be4fe22..a40a198888077ebb78b35366981fac6bf41aff23 100644 --- a/src/UI/DocumentViews/MpvControls.cc +++ b/src/UI/DocumentViews/MpvControls.cc @@ -14,17 +14,25 @@ MpvControls::MpvControls(MpvContainer *passedContainer, QWidget *parent) noexcep progressBar->setTracking(false); progressBar->setOrientation(Qt::Horizontal); - mpv->registerMpvDurationCallback([progressBar](double time) noexcept -> void { - progressBar->setMaximum(static_cast<int>(time)); + mpv->registerMpvDurationCallback([progressBar, this](double time) noexcept -> void { + timePosition = 0; + timeDuration = static_cast<int>(time); + progressBar->setMaximum(timeDuration); progressBar->setValue(0); }); - mpv->registerMpvTimeCallback([progressBar](double time) noexcept -> void { + mpv->registerMpvTimeCallback([progressBar, this](double time) noexcept -> void { if (!progressBar->isSliderDown()) { // The user is not pressing the slider - progressBar->setValue(static_cast<int>(time)); + timePosition = static_cast<int>(time); + progressBar->setValue(timePosition); } }); + connect(progressBar, &QAbstractSlider::valueChanged, this, [this](int value) noexcept -> void { + qDebug() << "Slider set to" << value << "max was" << timeDuration; + timePosition = value; + }); + auto *centralLayout = new QVBoxLayout(this); centralLayout->addWidget(progressBar); setLayout(centralLayout); diff --git a/src/UI/DocumentViews/MpvControls.hh b/src/UI/DocumentViews/MpvControls.hh index acb53d11362bf6f3d78629a64020fb87285a513c..ef57d29908328418726d40b9418dd457eade7851 100644 --- a/src/UI/DocumentViews/MpvControls.hh +++ b/src/UI/DocumentViews/MpvControls.hh @@ -14,6 +14,8 @@ class MpvControls final : public QWidget { private: MpvContainer *mpv{ nullptr }; + int timeDuration; + int timePosition; public: explicit MpvControls(MpvContainer *mpv, QWidget *parent) noexcept;