[vlc-commits] qt: add support for the restore playback functions
Pierre Lamot
git at videolan.org
Thu Jan 23 10:05:24 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Jan 10 16:33:58 2020 +0100| [3b88cdf5ef8f480ca46ea53c6ebc0365458cc2be] | committer: Hugo Beauzée-Luyssen
qt: add support for the restore playback functions
canRestorePlayback is stored as a boolean rather than a pure event
because the player view is likely to be loaded after the callback is called
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b88cdf5ef8f480ca46ea53c6ebc0365458cc2be
---
modules/gui/qt/player/player_controller.cpp | 25 ++++++++++++++++++++++++-
modules/gui/qt/player/player_controller.hpp | 6 ++++++
modules/gui/qt/player/player_controller_p.hpp | 2 ++
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/modules/gui/qt/player/player_controller.cpp b/modules/gui/qt/player/player_controller.cpp
index 129d4c1429..b7e39086e9 100644
--- a/modules/gui/qt/player/player_controller.cpp
+++ b/modules/gui/qt/player/player_controller.cpp
@@ -252,6 +252,9 @@ static void on_player_current_media_changed(vlc_player_t *, input_item_t *new_m
that->UpdateArt( newMediaPtr.get() );
that->UpdateMeta( newMediaPtr.get() );
+ that->m_canRestorePlayback = false;
+ emit q->playbackRestoreQueried();
+
RecentsMRL::getInstance( that->p_intf )->addRecent( newMediaPtr.get()->psz_uri );
emit q->inputChanged(true);
@@ -310,6 +313,8 @@ static void on_player_state_changed(vlc_player_t *, enum vlc_player_state state,
emit q->isMenuChanged( false );
that->m_isInteractive= false;
emit q->isInteractiveChanged( false );
+ that->m_canRestorePlayback = false;
+ emit q->playbackRestoreQueried();
that->m_teletextAvailable = false;
emit q->teletextAvailableChanged( false );
@@ -840,6 +845,16 @@ static void on_player_corks_changed(vlc_player_t *, unsigned, void *data)
msg_Dbg( that->p_intf, "on_player_corks_changed");
}
+static void on_player_playback_restore_queried(vlc_player_t *, void *data)
+{
+ PlayerControllerPrivate* that = static_cast<PlayerControllerPrivate*>(data);
+ msg_Dbg( that->p_intf, "on_playback_restore_queried");
+ that->callAsync([that](){
+ that->m_canRestorePlayback = true;
+ emit that->q_func()->playbackRestoreQueried();
+ });
+}
+
static void on_player_timer_update(const struct vlc_player_timer_point *point,
void *data)
{
@@ -950,7 +965,7 @@ static const struct vlc_player_cbs player_cbs = {
on_player_subitems_changed,
on_player_vout_changed,
on_player_corks_changed,
- nullptr
+ on_player_playback_restore_queried
};
static const struct vlc_player_vout_cbs player_vout_cbs = {
@@ -1502,6 +1517,13 @@ void PlayerController::updateTimeFromTimer()
updateTime(system_now, false);
}
+void PlayerController::restorePlaybackPos()
+{
+ Q_D(PlayerController);
+ vlc_player_locker lock{ d->m_player };
+ vlc_player_RestorePlaybackPos( d->m_player );
+}
+
//MISC
void PlayerController::setABloopState(ABLoopState state)
@@ -1697,6 +1719,7 @@ PRIMITIVETYPE_GETTER(bool, isSeekable, m_capabilities & VLC_PLAYER_CAP_SEEK)
PRIMITIVETYPE_GETTER(bool, isRewindable, m_capabilities & VLC_PLAYER_CAP_REWIND)
PRIMITIVETYPE_GETTER(bool, isPausable, m_capabilities & VLC_PLAYER_CAP_PAUSE)
PRIMITIVETYPE_GETTER(bool, isRateChangable, m_capabilities & VLC_PLAYER_CAP_CHANGE_RATE)
+PRIMITIVETYPE_GETTER(bool, canRestorePlayback, m_canRestorePlayback);
PRIMITIVETYPE_GETTER(float, getSubtitleFPS, m_subtitleFPS)
PRIMITIVETYPE_GETTER(bool, hasVideoOutput, m_hasVideo)
PRIMITIVETYPE_GETTER(float, getBuffering, m_buffering)
diff --git a/modules/gui/qt/player/player_controller.hpp b/modules/gui/qt/player/player_controller.hpp
index 703b9b56a8..3c792b47a9 100644
--- a/modules/gui/qt/player/player_controller.hpp
+++ b/modules/gui/qt/player/player_controller.hpp
@@ -125,6 +125,8 @@ public:
Q_PROPERTY(bool pausable READ isPausable NOTIFY pausableChanged)
Q_PROPERTY(bool ratechangable READ isRateChangable NOTIFY rateChangableChanged)
+ Q_PROPERTY(bool canRestorePlayback READ canRestorePlayback NOTIFY playbackRestoreQueried)
+
//tracks
Q_PROPERTY(TrackListModel* videoTracks READ getVideoTracks CONSTANT)
Q_PROPERTY(TrackListModel* audioTracks READ getAudioTracks CONSTANT)
@@ -273,6 +275,8 @@ public slots:
bool isRateChangable() const;
void updatePositionFromTimer();
void updateTimeFromTimer();
+ bool canRestorePlayback() const;
+ void restorePlaybackPos();
//tracks
TrackListModel* getVideoTracks();
@@ -365,6 +369,8 @@ signals:
void recordableChanged( bool );
void rateChangableChanged( bool );
+ void playbackRestoreQueried();
+
//tracks
void audioDelayChanged(VLCTick);
void subtitleDelayChanged(VLCTick);
diff --git a/modules/gui/qt/player/player_controller_p.hpp b/modules/gui/qt/player/player_controller_p.hpp
index 8a7bcc790b..c3f3dd4ea4 100644
--- a/modules/gui/qt/player/player_controller_p.hpp
+++ b/modules/gui/qt/player/player_controller_p.hpp
@@ -82,6 +82,8 @@ public:
float m_position = 0.f;
VLCTick m_length= 0;
+ bool m_canRestorePlayback = false;
+
int m_capabilities = 0;
//tracks
More information about the vlc-commits
mailing list