Skip to content

Commit

Permalink
qmlavplayer: mimic qtmultimedia's mediaObject
Browse files Browse the repository at this point in the history
signal connections are moved in beginClass() as in qtdeclarativeaudio
(MediaPlayer)
  • Loading branch information
sherpya committed Sep 22, 2014
1 parent d8f9082 commit fe80bce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions qml/QmlAV/QmlAVPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class QMLAV_EXPORT QmlAVPlayer : public QObject, public QQmlParserStatus
Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged)
Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
Q_PROPERTY(MediaMetaData *metaData READ metaData CONSTANT)
Q_PROPERTY(QObject *mediaObject READ mediaObject)

Q_PROPERTY(ChannelLayout channelLayout READ channelLayout WRITE setChannelLayout NOTIFY channelLayoutChanged)

Expand Down Expand Up @@ -126,6 +127,7 @@ class QMLAV_EXPORT QmlAVPlayer : public QObject, public QQmlParserStatus
void setAutoPlay(bool autoplay);

MediaMetaData *metaData() const;
QObject *mediaObject() const;

// "FFmpeg", "CUDA", "DXVA", "VAAPI" etc
QStringList videoCodecs() const;
Expand Down Expand Up @@ -168,6 +170,8 @@ public Q_SLOTS:
void videoCodecPriorityChanged();
void channelLayoutChanged();

void mediaObjectChanged();

private Q_SLOTS:
// connect to signals from player
void _q_started();
Expand Down
16 changes: 12 additions & 4 deletions qml/QmlAVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,21 @@ QmlAVPlayer::QmlAVPlayer(QObject *parent) :
, mpPlayer(0)
, mChannelLayout(ChannelLayoutAuto)
{
mpPlayer = new AVPlayer(this); //in componentComplete()?
}

void QmlAVPlayer::classBegin()
{
mpPlayer = new AVPlayer(this);
connect(mpPlayer, SIGNAL(paused(bool)), SLOT(_q_paused(bool)));
connect(mpPlayer, SIGNAL(started()), SLOT(_q_started()));
connect(mpPlayer, SIGNAL(stopped()), SLOT(_q_stopped()));
connect(mpPlayer, SIGNAL(positionChanged(qint64)), SIGNAL(positionChanged()));

mVideoCodecs << "FFmpeg";
}

void QmlAVPlayer::classBegin()
{
m_metaData.reset(new MediaMetaData());

emit mediaObjectChanged();
}

void QmlAVPlayer::componentComplete()
Expand Down Expand Up @@ -169,6 +172,11 @@ MediaMetaData* QmlAVPlayer::metaData() const
return m_metaData.data();
}

QObject* QmlAVPlayer::mediaObject() const
{
return mpPlayer;
}

QStringList QmlAVPlayer::videoCodecs() const
{
return VideoDecodersToNames(QtAV::GetRegistedVideoDecoderIds());
Expand Down

0 comments on commit fe80bce

Please sign in to comment.