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)
This commit is contained in:
Alexandre Moreno 2015-11-01 16:27:13 +08:00 committed by Sebastian Dröge
parent 736ba93518
commit 16a9b70155
2 changed files with 21 additions and 2 deletions

View file

@ -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);

View file

@ -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