Adding hasAudio and hasVideo properties to QML MediaPlayer

Adding hasAudio and hasVideo to MediaPlayer QML object to allow users
to determine whether the current media has audio and/or video
streams. Also adding notifies for when these properties change.

Change-Id: Ife7606e148f0c0ad558b4019c68c70973c199c08
Reviewed-by: Sergey Dubitskiy
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
Mithra Pattison
2011-12-29 11:19:19 +10:00
committed by Qt by Nokia
parent b094a91c9d
commit c13a13c486
2 changed files with 37 additions and 0 deletions

View File

@@ -260,6 +260,28 @@ QDeclarativeAudio::Status QDeclarativeAudio::status() const
This property holds whether the audio output is muted.
*/
/*!
\qmlproperty bool Audio::hasAudio
This property holds whether the media contains audio.
*/
bool QDeclarativeAudio::hasAudio() const
{
return !m_complete ? false : m_playerControl->isAudioAvailable();
}
/*!
\qmlproperty bool Audio::hasVideo
This property holds whether the media contains video.
*/
bool QDeclarativeAudio::hasVideo() const
{
return !m_complete ? false : m_playerControl->isVideoAvailable();
}
/*!
\qmlproperty real Audio::bufferProgress
@@ -305,6 +327,14 @@ QDeclarativeAudio::Error QDeclarativeAudio::error() const
void QDeclarativeAudio::classBegin()
{
setObject(this);
if (m_mediaService) {
connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)),
this, SIGNAL(hasAudioChanged()));
connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)),
this, SIGNAL(hasVideoChanged()));
}
emit mediaObjectChanged();
}

View File

@@ -78,6 +78,8 @@ class QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public Q
Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
Q_PROPERTY(bool hasAudio READ hasAudio NOTIFY hasAudioChanged)
Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
@@ -121,6 +123,9 @@ public:
QDeclarativeAudio(QObject *parent = 0);
~QDeclarativeAudio();
bool hasAudio() const;
bool hasVideo() const;
Status status() const;
Error error() const;
@@ -153,6 +158,8 @@ Q_SIGNALS:
void volumeChanged();
void mutedChanged();
void hasAudioChanged();
void hasVideoChanged();
void bufferProgressChanged();