From 16a9b70155d25c7e32b22e816c04369009ce07ff Mon Sep 17 00:00:00 2001 From: Alexandre Moreno Date: Sun, 1 Nov 2015 16:27:13 +0800 Subject: [PATCH] playback/player: qt: add autoPlay property When set to true will play current media set immediately, and if set to false will show first frame (i.e. go to pause state) --- playback/player/qt/qgstplayer.cpp | 17 +++++++++++++++++ playback/player/qt/qgstplayer.h | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/playback/player/qt/qgstplayer.cpp b/playback/player/qt/qgstplayer.cpp index 4fcc975809..8117b7439b 100644 --- a/playback/player/qt/qgstplayer.cpp +++ b/playback/player/qt/qgstplayer.cpp @@ -340,6 +340,7 @@ Player::Player(QObject *parent, VideoRenderer *renderer) , mediaInfo_() , videoAvailable_(false) , subtitleEnabled_(false) + , autoPlay_(false) { player_ = gst_player_new_full(renderer ? renderer->renderer() : 0, @@ -443,9 +444,25 @@ Player::onMediaInfoUpdated(Player *player, GstPlayerMediaInfo *media_info) emit player->mediaInfoChanged(); } + +bool Player::autoPlay() const +{ + return autoPlay_; +} + +void Player::setAutoPlay(bool auto_play) +{ + autoPlay_ = auto_play; + + if (autoPlay_) { + connect(this, SIGNAL(endOfStream()), SLOT(next())); + } +} + QUrl Player::source() const { Q_ASSERT(player_ != 0); + QString url = QString::fromLocal8Bit(gst_player_get_uri(player_)); return QUrl(url); diff --git a/playback/player/qt/qgstplayer.h b/playback/player/qt/qgstplayer.h index c060bc99a1..afbefd43fc 100644 --- a/playback/player/qt/qgstplayer.h +++ b/playback/player/qt/qgstplayer.h @@ -57,6 +57,7 @@ class Player : public QObject Q_PROPERTY(QVariant currentSubtitle READ currentSubtitle WRITE setCurrentSubtitle) Q_PROPERTY(bool subtitleEnabled READ isSubtitleEnabled WRITE setSubtitleEnabled NOTIFY subtitleEnabledChanged) + Q_PROPERTY(bool autoPlay READ autoPlay WRITE setAutoPlay) Q_ENUMS(State) @@ -89,12 +90,11 @@ public: QVariant currentSubtitle() const; bool isSubtitleEnabled() const; quint32 positionUpdateInterval() const; - + bool autoPlay() const; signals: void stateChanged(State new_state); void bufferingChanged(int percent); - void enfOfStream(); void positionUpdated(qint64 new_position); void durationChanged(qint64 duration); void resolutionChanged(QSize resolution); @@ -119,6 +119,7 @@ public slots: void setCurrentSubtitle(QVariant track); void setSubtitleEnabled(bool enabled); void setPositionUpdateInterval(quint32 interval); + void setAutoPlay(bool auto_play); private: Q_DISABLE_COPY(Player) @@ -137,6 +138,7 @@ private: MediaInfo *mediaInfo_; bool videoAvailable_; bool subtitleEnabled_; + bool autoPlay_; }; class VideoRenderer