Skip to content
Extraits de code Groupes Projets
Vérifiée Valider b308ddd4 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

UI: Use std::chrono for the time with the mpv slider

parent 2e150f56
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!15Video playback with mpv
......@@ -18,22 +18,22 @@ MpvControls::MpvControls(MpvContainer *passedContainer, QWidget *parent) noexcep
progressBar->setOrientation(Qt::Horizontal);
mpv->registerMpvDurationCallback([progressBar, this](double time) noexcept -> void {
timePosition = 0;
timeDuration = static_cast<int>(time);
progressBar->setMaximum(timeDuration);
timePosition = chrono::seconds::zero();
timeDuration = chrono::seconds(static_cast<long>(time));
progressBar->setMaximum(static_cast<int>(timeDuration.count()));
progressBar->setValue(0);
});
mpv->registerMpvTimeCallback([progressBar, this](double time) noexcept -> void {
if (!progressBar->isSliderDown()) {
// The user is not pressing the slider
timePosition = static_cast<int>(time);
progressBar->setValue(timePosition);
timePosition = chrono::seconds(static_cast<long>(time));
progressBar->setValue(static_cast<int>(timePosition.count()));
}
});
connect(progressBar, &QAbstractSlider::valueChanged, this, [this](int value) noexcept -> void {
qDebug() << "Slider set to" << value << "max was" << timeDuration;
timePosition = value;
qDebug() << "Slider set to" << value << "max was" << timeDuration.count();
timePosition = chrono::seconds(value);
});
connect(togglePlaybackButton, &QAbstractButton::clicked, mpv, &MpvContainer::mpvTogglePlayback);
......
......@@ -4,6 +4,9 @@
#error "This is a C++ header"
#endif
#include <chrono>
namespace chrono = std::chrono;
namespace Vivy
{
class MpvContainer;
......@@ -14,8 +17,8 @@ class MpvControls final : public QWidget {
private:
MpvContainer *mpv{ nullptr };
int timeDuration;
int timePosition;
chrono::seconds timeDuration;
chrono::seconds timePosition;
public:
explicit MpvControls(MpvContainer *mpv, QWidget *parent) noexcept;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter