summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Moreno <alexmorenocano@gmail.com>2015-11-01 16:27:13 +0800
committerSebastian Dröge <sebastian@centricular.com>2015-11-01 11:25:27 +0200
commit055a51de80d790529651ee05553b5d5a8e76903d (patch)
tree2366feeadc299ddf3392bfb91661f760edd37a2e
parent48bd41e5018d9bbd7d3fb65603821d7828b1d9e6 (diff)
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)
-rw-r--r--qt/qgstplayer.cpp17
-rw-r--r--qt/qgstplayer.h6
2 files changed, 21 insertions, 2 deletions
diff --git a/qt/qgstplayer.cpp b/qt/qgstplayer.cpp
index 4fcc975..8117b74 100644
--- a/qt/qgstplayer.cpp
+++ b/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/qt/qgstplayer.h b/qt/qgstplayer.h
index c060bc9..afbefd4 100644
--- a/qt/qgstplayer.h
+++ b/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