summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2013-10-17 12:22:42 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-18 09:21:18 +0200
commitd7dd22b9955ffde6d3c663655d9f9d4a58ca3894 (patch)
treefda246fcb42f08d09b030e0e3334620a92474fd8
parent068169528c5e8a281b448c21d6eb5dbd88911dc0 (diff)
Correctly clear the current media in Audio and MediaPlayer qml elements.v5.2.0-beta1
When setting the source to an empty string in these elements, pass an empty QMediaContent to the backend rather than an empty URL. The former is the correct way to clear the current media. Task-number: QTBUG-34125 Change-Id: I3dd7b07abc0bd23a1253c8c0e075b174c17a4d3f Reviewed-by: Christian Stromme <christian.stromme@digia.com>
-rw-r--r--src/imports/multimedia/qdeclarativeaudio.cpp15
-rw-r--r--src/imports/multimedia/qdeclarativeaudio_p.h1
2 files changed, 9 insertions, 7 deletions
diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp
index 1da92c30..bce0b7e2 100644
--- a/src/imports/multimedia/qdeclarativeaudio.cpp
+++ b/src/imports/multimedia/qdeclarativeaudio.cpp
@@ -183,8 +183,9 @@ void QDeclarativeAudio::setSource(const QUrl &url)
return;
m_source = url;
+ m_content = m_source.isEmpty() ? QMediaContent() : m_source;
m_loaded = false;
- if (m_complete && (m_autoLoad || url.isEmpty() || m_autoPlay)) {
+ if (m_complete && (m_autoLoad || m_content.isNull() || m_autoPlay)) {
if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
m_error = QMediaPlayer::NoError;
m_errorString = QString();
@@ -192,7 +193,7 @@ void QDeclarativeAudio::setSource(const QUrl &url)
emit errorChanged();
}
- m_player->setMedia(m_source, 0);
+ m_player->setMedia(m_content, 0);
m_loaded = true;
}
else
@@ -245,7 +246,7 @@ void QDeclarativeAudio::setPlaybackState(QMediaPlayer::State playbackState)
switch (playbackState){
case (QMediaPlayer::PlayingState):
if (!m_loaded) {
- m_player->setMedia(m_source, 0);
+ m_player->setMedia(m_content, 0);
m_player->setPosition(m_position);
m_loaded = true;
}
@@ -254,7 +255,7 @@ void QDeclarativeAudio::setPlaybackState(QMediaPlayer::State playbackState)
case (QMediaPlayer::PausedState):
if (!m_loaded) {
- m_player->setMedia(m_source, 0);
+ m_player->setMedia(m_content, 0);
m_player->setPosition(m_position);
m_loaded = true;
}
@@ -681,8 +682,8 @@ void QDeclarativeAudio::componentComplete()
if (!qFuzzyCompare(m_playbackRate, qreal(1.0)))
m_player->setPlaybackRate(m_playbackRate);
- if (!m_source.isEmpty() && (m_autoLoad || m_autoPlay)) {
- m_player->setMedia(m_source, 0);
+ if (!m_content.isNull() && (m_autoLoad || m_autoPlay)) {
+ m_player->setMedia(m_content, 0);
m_loaded = true;
if (m_position > 0)
m_player->setPosition(m_position);
@@ -691,7 +692,7 @@ void QDeclarativeAudio::componentComplete()
m_complete = true;
if (m_autoPlay) {
- if (m_source.isEmpty()) {
+ if (m_content.isNull()) {
m_player->stop();
} else {
m_player->play();
diff --git a/src/imports/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h
index b8a75c65..1c67bc3a 100644
--- a/src/imports/multimedia/qdeclarativeaudio_p.h
+++ b/src/imports/multimedia/qdeclarativeaudio_p.h
@@ -257,6 +257,7 @@ private:
QMediaPlayer::Error m_error;
QString m_errorString;
QUrl m_source;
+ QMediaContent m_content;
QScopedPointer<QDeclarativeMediaMetaData> m_metaData;