[vlc-commits] qt: expose remaining time in player controller

Pierre Lamot git at videolan.org
Thu Aug 29 10:44:43 CEST 2019


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Aug  7 14:44:31 2019 +0200| [18a780a89176cc04e00488aadfbfa060630bc937] | committer: Jean-Baptiste Kempf

qt: expose remaining time in player controller

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=18a780a89176cc04e00488aadfbfa060630bc937
---

 modules/gui/qt/components/player_controller.cpp   | 12 ++++++++++++
 modules/gui/qt/components/player_controller.hpp   |  5 +++--
 modules/gui/qt/components/player_controller_p.hpp |  1 +
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt/components/player_controller.cpp b/modules/gui/qt/components/player_controller.cpp
index f244f3f3a0..1dcd4b4183 100644
--- a/modules/gui/qt/components/player_controller.cpp
+++ b/modules/gui/qt/components/player_controller.cpp
@@ -397,6 +397,11 @@ static void on_player_position_changed(vlc_player_t *player, vlc_tick_t time, fl
         emit q->positionChanged(pos);
         that->m_time = time;
         emit q->timeChanged(time);
+        if ( time != VLC_TICK_INVALID && length != VLC_TICK_INVALID )
+            that->m_remainingTime = length - time;
+        else
+            that->m_remainingTime = VLC_TICK_INVALID;
+        emit q->remainingTimeChanged(that->m_remainingTime);
         emit that->q_func()->positionUpdated(pos, time, SEC_FROM_VLC_TICK(length) );
     });
 }
@@ -410,6 +415,12 @@ static void on_player_length_changed(vlc_player_t *player, vlc_tick_t new_length
         PlayerController* q = that->q_func();
         that->m_length = new_length;
         emit q->lengthChanged(new_length);
+
+        if ( time != VLC_TICK_INVALID && new_length != VLC_TICK_INVALID )
+            that->m_remainingTime = new_length - time;
+        else
+            that->m_remainingTime = VLC_TICK_INVALID;
+        emit q->remainingTimeChanged(that->m_remainingTime);
         emit that->q_func()->positionUpdated( pos, time, SEC_FROM_VLC_TICK(new_length) );
     });
 
@@ -1548,6 +1559,7 @@ QABSTRACTLIST_GETTER( VLCVarChoiceModel, getAudioVisualizations, m_audioVisualiz
 PRIMITIVETYPE_GETTER(PlayerController::PlayingState, getPlayingState, m_playing_status)
 PRIMITIVETYPE_GETTER(QString, getName, m_name)
 PRIMITIVETYPE_GETTER(VLCTick, getTime, m_time)
+PRIMITIVETYPE_GETTER(VLCTick, getRemainingTime, m_remainingTime)
 PRIMITIVETYPE_GETTER(float, getPosition, m_position)
 PRIMITIVETYPE_GETTER(VLCTick, getLength, m_length)
 PRIMITIVETYPE_GETTER(VLCTick, getAudioDelay, m_audioDelay)
diff --git a/modules/gui/qt/components/player_controller.hpp b/modules/gui/qt/components/player_controller.hpp
index f1e17827df..7fb4384886 100644
--- a/modules/gui/qt/components/player_controller.hpp
+++ b/modules/gui/qt/components/player_controller.hpp
@@ -116,6 +116,7 @@ public:
     Q_PROPERTY(MediaStopAction mediaStopAction READ getMediaStopAction WRITE setMediaStopAction NOTIFY mediaStopActionChanged)
 
     Q_PROPERTY(VLCTick time READ getTime WRITE setTime NOTIFY timeChanged)
+    Q_PROPERTY(VLCTick remainingTime READ getRemainingTime NOTIFY remainingTimeChanged)
     Q_PROPERTY(float position READ getPosition WRITE setPosition NOTIFY positionChanged)
     Q_PROPERTY(VLCTick length READ getLength NOTIFY lengthChanged)
 
@@ -260,6 +261,7 @@ public slots:
     void setMediaStopAction(MediaStopAction );
     VLCTick getTime() const;
     void setTime(VLCTick);
+    VLCTick getRemainingTime() const;
     float getPosition() const;
     void setPosition(float);
     VLCTick getLength() const;
@@ -347,13 +349,12 @@ signals:
     void mediaStopActionChanged( MediaStopAction );
 
     void timeChanged( VLCTick );
+    void remainingTimeChanged( VLCTick );
     void positionChanged( float );
     void lengthChanged( VLCTick );
     void positionUpdated( float , VLCTick, int );
     void seekRequested( float pos ); //not exposed through Q_PROPERTY
 
-    void remainingTimeChanged( bool );  //FIXME
-
     void seekableChanged( bool );
     void rewindableChanged( bool );
     void pausableChanged( bool );
diff --git a/modules/gui/qt/components/player_controller_p.hpp b/modules/gui/qt/components/player_controller_p.hpp
index 653ef46592..dcc28c929f 100644
--- a/modules/gui/qt/components/player_controller_p.hpp
+++ b/modules/gui/qt/components/player_controller_p.hpp
@@ -75,6 +75,7 @@ public:
     PlayerController::MediaStopAction m_mediaStopAction = PlayerController::MEDIA_STOPPED_CONTINUE;
 
     VLCTick      m_time = 0;
+    VLCTick      m_remainingTime = 0;
     float           m_position = 0.f;
     VLCTick      m_length= 0;
 



More information about the vlc-commits mailing list