summaryrefslogtreecommitdiffstats
path: root/src/imports/multimedia/qdeclarativevideo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/multimedia/qdeclarativevideo.cpp')
-rw-r--r--src/imports/multimedia/qdeclarativevideo.cpp64
1 files changed, 36 insertions, 28 deletions
diff --git a/src/imports/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp
index 80c0ba4..6aff9bd 100644
--- a/src/imports/multimedia/qdeclarativevideo.cpp
+++ b/src/imports/multimedia/qdeclarativevideo.cpp
@@ -100,17 +100,6 @@ QDeclarativeVideo::QDeclarativeVideo(QDeclarativeItem *parent)
m_graphicsItem = new QGraphicsVideoItem(this);
connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)),
this, SLOT(_q_nativeSizeChanged(QSizeF)));
-
- setObject(this);
-
- if (m_mediaService) {
- connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)),
- this, SIGNAL(hasAudioChanged()));
- connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)),
- this, SIGNAL(hasVideoChanged()));
-
- m_graphicsItem->setMediaObject(m_mediaObject);
- }
}
QDeclarativeVideo::~QDeclarativeVideo()
@@ -127,6 +116,14 @@ QDeclarativeVideo::~QDeclarativeVideo()
*/
/*!
+ \qmlproperty url Audio:autoLoad
+
+ This property indicates if loading of media should begin immediately.
+
+ Defaults to true, if false media will not be loaded until playback is started.
+*/
+
+/*!
\qmlproperty bool Video::playing
This property holds whether the media is playing.
@@ -253,7 +250,7 @@ QDeclarativeVideo::Status QDeclarativeVideo::status() const
bool QDeclarativeVideo::hasAudio() const
{
- return m_playerControl->isAudioAvailable();
+ return m_playerControl == 0 ? false : m_playerControl->isAudioAvailable();
}
/*!
@@ -264,7 +261,7 @@ bool QDeclarativeVideo::hasAudio() const
bool QDeclarativeVideo::hasVideo() const
{
- return m_playerControl->isVideoAvailable();
+ return m_playerControl == 0 ? false : m_playerControl->isVideoAvailable();
}
/*!
@@ -356,12 +353,11 @@ void QDeclarativeVideo::setFillMode(FillMode mode)
void QDeclarativeVideo::play()
{
- m_playerControl->play();
+ if (m_playerControl == 0)
+ return;
- if (m_paused) {
- m_paused = false;
- emit pausedChanged();
- }
+ setPaused(false);
+ setPlaying(true);
}
/*!
@@ -374,12 +370,11 @@ void QDeclarativeVideo::play()
void QDeclarativeVideo::pause()
{
- m_playerControl->pause();
+ if (m_playerControl == 0)
+ return;
- if (!m_paused && m_state == QMediaPlayer::PausedState) {
- m_paused = true;
- emit pausedChanged();
- }
+ setPaused(true);
+ setPlaying(true);
}
/*!
@@ -392,12 +387,11 @@ void QDeclarativeVideo::pause()
void QDeclarativeVideo::stop()
{
- m_playerControl->stop();
+ if (m_playerControl == 0)
+ return;
- if (m_paused) {
- m_paused = false;
- emit pausedChanged();
- }
+ setPlaying(false);
+ setPaused(false);
}
void QDeclarativeVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
@@ -411,6 +405,20 @@ void QDeclarativeVideo::geometryChanged(const QRectF &newGeometry, const QRectF
QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
}
+void QDeclarativeVideo::componentComplete()
+{
+ setObject(this);
+
+ if (m_mediaService) {
+ connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)),
+ this, SIGNAL(hasAudioChanged()));
+ connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)),
+ this, SIGNAL(hasVideoChanged()));
+
+ m_graphicsItem->setMediaObject(m_mediaObject);
+ }
+}
+
QT_END_NAMESPACE
// ***************************************