summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAngus Cummings <angus.cummings@nokia.com>2012-02-03 11:49:47 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-08 03:48:51 +0100
commita94c8a1ac26f4a5a79d63672d21538d016bc09f4 (patch)
treeaaadf76db98dbf9d1ba228c7e0c68868242f0355 /src
parent66b86ba5812ba15c177f7c6b2916bca4376749ce (diff)
API changes to QML element MediaPlayer aka Audio
Changed Video.qml for new API Removed lowercase enum copies, replaced with calling parent (VideoOutput, MediaPlayer) enums Removed properties playing, paused Removed signals started, resumed Added readonly property playbackState Added signal playing Added autoPlay property Fixed unit tests for new API Added backwards compatibility for QtMultimedia 4 Change-Id: I27c91cd46d91402b8c4c42bb7d4961ad67909aeb Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/multimedia/Video.qml92
-rw-r--r--src/imports/multimedia/Video_4.qml99
-rw-r--r--src/imports/multimedia/multimedia.cpp5
-rw-r--r--src/imports/multimedia/multimedia.pro11
-rw-r--r--src/imports/multimedia/qdeclarativeaudio.cpp72
-rw-r--r--src/imports/multimedia/qdeclarativeaudio_4.cpp729
-rw-r--r--src/imports/multimedia/qdeclarativeaudio_p.h23
-rw-r--r--src/imports/multimedia/qdeclarativeaudio_p_4.h190
-rw-r--r--src/imports/multimedia/qdeclarativemediabase.cpp165
-rw-r--r--src/imports/multimedia/qdeclarativemediabase_4.cpp567
-rw-r--r--src/imports/multimedia/qdeclarativemediabase_p.h32
-rw-r--r--src/imports/multimedia/qdeclarativemediabase_p_4.h188
-rw-r--r--src/imports/multimedia/qmldir1
13 files changed, 1971 insertions, 203 deletions
diff --git a/src/imports/multimedia/Video.qml b/src/imports/multimedia/Video.qml
index e62e98a8a..a8f67e79c 100644
--- a/src/imports/multimedia/Video.qml
+++ b/src/imports/multimedia/Video.qml
@@ -95,17 +95,16 @@ Item {
area.
\list
- \o stretch - the video is scaled to fit.
- \o preserveAspectFit - the video is scaled uniformly to fit without
+ \o VideoOutput.Stretch - the video is scaled to fit
+ \o VideoOutput.PreserveAspectFit - the video is scaled uniformly to fit without
cropping
- \o preserveAspectCrop - the video is scaled uniformly to fill, cropping
+ \o VideoOuput.PreserveAspectCrop - the video is scaled uniformly to fill, cropping
if necessary
\endlist
Because this element is a convenience element in QML, it does not
- support enumerations directly. In contrast to \l VideoOutput and other
- elements, the values to set for fillMode all start with lowercase
- letters to work around this.
+ support enumerations directly, so enumerations from VideoOuput are
+ used to access the available fill modes.
The default fill mode is preserveAspectFit.
*/
@@ -119,15 +118,24 @@ Item {
*/
property alias orientation: videoOut.orientation
- /* Properties to emulate enumeration for fillMode, documented above */
- /*! \internal */
- readonly property int stretch: VideoOutput.Stretch
- /*! \internal */
- readonly property int preserveAspectFit: VideoOutput.PreserveAspectFit
- /*! \internal */
- readonly property int preserveAspectCrop: VideoOutput.PreserveAspectCrop
/*** Properties of MediaPlayer ***/
+
+ /*!
+ \qmlproperty enumeration Video::playbackState
+
+ This read only property indicates the playback state of the media.
+
+ \list
+ \o MediaPlayer.PlayingState - the media is playing
+ \o MediaPlayer.PausedState - the media is paused
+ \o MediaPlayer.StoppedState - the media is stopped
+ \endlist
+
+ The default state is MediaPlayer.StoppedState.
+ */
+ property alias playbackState: player.playbackState
+
/*!
\qmlproperty bool Video::autoLoad
@@ -195,15 +203,6 @@ Item {
property alias muted: player.muted
/*!
- \qmlproperty bool Video::paused
-
- This property holds whether the media is paused.
-
- Defaults to false, and can be set to true to pause playback.
- */
- property alias paused: player.paused
-
- /*!
\qmlproperty real Video::playbackRate
This property holds the rate at which video is played at as a multiple
@@ -212,15 +211,6 @@ Item {
property alias playbackRate: player.playbackRate
/*!
- \qmlproperty bool Video::playing
-
- This property holds whether the media is playing.
-
- Defaults to false, and can be set to true to start playback.
- */
- property alias playing: player.playing
-
- /*!
\qmlproperty int Video::position
This property holds the current playback position in milliseconds.
@@ -269,17 +259,19 @@ Item {
property alias volume: player.volume
/*!
- \qmlsignal Video::resumed()
+ \qmlproperty bool Video::autoPlay
- This signal is emitted when playback is resumed from the paused state.
+ This property determines whether the media should begin playback automatically.
*/
- signal resumed
+ property alias autoPlay: player.autoPlay
+
/*!
- \qmlsignal Video::started()
+ \qmlsignal Video::paused()
- This signal is emitted when playback is started.
+ This signal is emitted when playback is paused.
*/
- signal started
+ signal paused
+
/*!
\qmlsignal Video::stopped()
@@ -287,6 +279,19 @@ Item {
*/
signal stopped
+ /*!
+ \qmlsignal Video::playing()
+
+ This signal is emitted when playback is started or continued.
+ */
+ signal playing
+
+ /*!
+ \qmlsignal Video::playbackStateChanged()
+
+ This signal is emitted whenever the state of playback changes.
+ */
+ signal playbackStateChanged
VideoOutput {
id: videoOut
@@ -296,18 +301,17 @@ Item {
MediaPlayer {
id: player
- onResumed: video.resumed()
- onStarted: video.started()
+ onPaused: video.paused()
onStopped: video.stopped()
+ onPlaying: video.playing()
+
+ onPlaybackStateChanged: video.playbackStateChanged()
}
/*!
\qmlmethod Video::play()
Starts playback of the media.
-
- Sets the \l playing property to true, and the \l paused property to
- false.
*/
function play() {
player.play();
@@ -317,8 +321,6 @@ Item {
\qmlmethod Video::pause()
Pauses playback of the media.
-
- Sets the \l playing and \l paused properties to true.
*/
function pause() {
player.pause();
@@ -328,8 +330,6 @@ Item {
\qmlmethod Video::stop()
Stops playback of the media.
-
- Sets the \l playing and \l paused properties to false.
*/
function stop() {
player.stop();
diff --git a/src/imports/multimedia/Video_4.qml b/src/imports/multimedia/Video_4.qml
new file mode 100644
index 000000000..aab44515f
--- /dev/null
+++ b/src/imports/multimedia/Video_4.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtMultimedia 4.0
+
+Item {
+ id: video
+
+ property alias fillMode: videoOut.fillMode
+ property alias orientation: videoOut.orientation
+
+ readonly property int stretch: VideoOutput.Stretch
+ readonly property int preserveAspectFit: VideoOutput.PreserveAspectFit
+ readonly property int preserveAspectCrop: VideoOutput.PreserveAspectCrop
+
+ property alias autoLoad: player.autoLoad
+ property alias bufferProgress: player.bufferProgress
+ property alias duration: player.duration
+ property alias error: player.error
+ property alias errorString: player.errorString
+ property alias metaData: player.metaData
+ property alias muted: player.muted
+ property alias paused: player.paused
+ property alias playbackRate: player.playbackRate
+ property alias playing: player.playing
+ property alias position: player.position
+ property alias seekable: player.seekable
+ property alias source: player.source
+ property alias status: player.status
+ property alias volume: player.volume
+
+ signal resumed
+ signal started
+ signal stopped
+
+ VideoOutput {
+ id: videoOut
+ anchors.fill: video
+ source: player
+ }
+
+ MediaPlayer {
+ id: player
+ onResumed: video.resumed()
+ onStarted: video.started()
+ onStopped: video.stopped()
+ }
+
+ function play() {
+ player.play();
+ }
+
+ function pause() {
+ player.pause();
+ }
+
+ function stop() {
+ player.stop();
+ }
+}
diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp
index 46e6a9384..7a7a79862 100644
--- a/src/imports/multimedia/multimedia.cpp
+++ b/src/imports/multimedia/multimedia.cpp
@@ -47,6 +47,7 @@
#include "qdeclarativemediametadata_p.h"
#include "qdeclarativeaudio_p.h"
+#include "qdeclarativeaudio_p_4.h"
#include "qdeclarativevideooutput_p.h"
#include "qdeclarativeradio_p.h"
#include "qdeclarativeradiodata_p.h"
@@ -74,8 +75,8 @@ public:
|| QLatin1String(uri) == QLatin1String("Qt.multimediakit"));
qmlRegisterType<QSoundEffect>(uri, 4, 0, "SoundEffect");
- qmlRegisterType<QDeclarativeAudio>(uri, 4, 0, "Audio");
- qmlRegisterType<QDeclarativeAudio>(uri, 4, 0, "MediaPlayer");
+ qmlRegisterType<QDeclarativeAudio_4>(uri, 4, 0, "Audio");
+ qmlRegisterType<QDeclarativeAudio_4>(uri, 4, 0, "MediaPlayer");
qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput");
qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio");
qmlRegisterType<QDeclarativeRadioData>(uri, 4, 0, "RadioData");
diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro
index f9c7f6e8a..df01cc6b6 100644
--- a/src/imports/multimedia/multimedia.pro
+++ b/src/imports/multimedia/multimedia.pro
@@ -27,7 +27,9 @@ HEADERS += \
qdeclarativecamerafocus_p.h \
qdeclarativecameraimageprocessing_p.h \
qdeclarativecamerapreviewprovider_p.h \
- qdeclarativetorch_p.h
+ qdeclarativetorch_p.h \
+ qdeclarativeaudio_p_4.h \
+ qdeclarativemediabase_p_4.h
SOURCES += \
multimedia.cpp \
@@ -48,10 +50,13 @@ SOURCES += \
qdeclarativecamerafocus.cpp \
qdeclarativecameraimageprocessing.cpp \
qdeclarativecamerapreviewprovider.cpp \
- qdeclarativetorch.cpp
+ qdeclarativetorch.cpp \
+ qdeclarativemediabase_4.cpp \
+ qdeclarativeaudio_4.cpp
OTHER_FILES += \
- Video.qml
+ Video_4.qml \
+ Video.qml
qmldir.files += $$PWD/qmldir $$PWD/Video.qml
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp
index 3fb4ae7eb..4e84f557b 100644
--- a/src/imports/multimedia/qdeclarativeaudio.cpp
+++ b/src/imports/multimedia/qdeclarativeaudio.cpp
@@ -166,7 +166,7 @@ QDeclarativeAudio::~QDeclarativeAudio()
Starts playback of the media.
- Sets the \l playing property to true, and the \l paused property to false.
+ Sets the \l playbackState property to PlayingState.
*/
void QDeclarativeAudio::play()
@@ -174,8 +174,7 @@ void QDeclarativeAudio::play()
if (!m_complete)
return;
- setPaused(false);
- setPlaying(true);
+ setPlaybackState(QMediaPlayer::PlayingState);
}
/*!
@@ -183,7 +182,7 @@ void QDeclarativeAudio::play()
Pauses playback of the media.
- Sets the \l playing and \l paused properties to true.
+ Sets the \l playbackState property to PausedState.
*/
void QDeclarativeAudio::pause()
@@ -191,8 +190,7 @@ void QDeclarativeAudio::pause()
if (!m_complete)
return;
- setPaused(true);
- setPlaying(true);
+ setPlaybackState(QMediaPlayer::PausedState);
}
/*!
@@ -200,7 +198,7 @@ void QDeclarativeAudio::pause()
Stops playback of the media.
- Sets the \l playing and \l paused properties to false.
+ Sets the \l playbackState property to StoppedState.
*/
void QDeclarativeAudio::stop()
@@ -208,8 +206,7 @@ void QDeclarativeAudio::stop()
if (!m_complete)
return;
- setPlaying(false);
- setPaused(false);
+ setPlaybackState(QMediaPlayer::StoppedState);
}
/*!
@@ -227,43 +224,28 @@ void QDeclarativeAudio::stop()
*/
/*!
- \qmlproperty bool Audio::playing
+ \qmlsignal Audio::playbackStateChanged()
- This property holds whether the media is playing.
-
- Defaults to false, and can be set to true to start playback.
+ This handler is called when the \l playbackState property is altered.
*/
-/*!
- \qmlproperty bool Audio::paused
-
- This property holds whether the media is paused.
-
- Defaults to false, and can be set to true to pause playback.
-*/
/*!
- \qmlsignal Audio::onStarted()
-
- This handler is called when playback is started.
-*/
+ \qmlsignal Audio::paused()
-/*!
- \qmlsignal Audio::onResumed()
-
- This handler is called when playback is resumed from the paused state.
+ This handler is called when playback is paused.
*/
/*!
- \qmlsignal Audio::onPaused()
+ \qmlsignal Audio::stopped()
- This handler is called when playback is paused.
+ This handler is called when playback is stopped.
*/
/*!
- \qmlsignal Audio::onStopped()
+ \qmlsignal Audio::playing()
- This handler is called when playback is stopped.
+ This handler is called when playback is started or resumed.
*/
/*!
@@ -289,6 +271,32 @@ QDeclarativeAudio::Status QDeclarativeAudio::status() const
return Status(m_status);
}
+
+/*!
+ \qmlproperty enumeration Audio::playbackState
+
+ This property holds the state of media playback. It can be one of:
+
+ \list
+ \o PlayingState - the media is currently playing.
+ \o PausedState - playback of the media has been suspended.
+ \o StoppedState - playback of the media is yet to begin.
+ \endlist
+*/
+
+QDeclarativeAudio::PlaybackState QDeclarativeAudio::playbackState() const
+{
+ return PlaybackState(m_playbackState);
+}
+
+/*!
+ \qmlproperty int Audio::autoPlay
+
+ This property controls whether the media will begin to play on start up.
+
+ Defaults to false, if set true the value of autoLoad will be overwritten to true.
+*/
+
/*!
\qmlproperty int Audio::duration
diff --git a/src/imports/multimedia/qdeclarativeaudio_4.cpp b/src/imports/multimedia/qdeclarativeaudio_4.cpp
new file mode 100644
index 000000000..5cff803c7
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativeaudio_4.cpp
@@ -0,0 +1,729 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeaudio_p_4.h"
+
+#include <qmediaplayercontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+
+/*!
+ \qmlclass Audio QDeclarativeAudio
+ \brief The Audio element allows you to add audio playback to a scene.
+
+ \ingroup multimedia_qml
+
+ This element is part of the \bold{QtMultimedia 5.0} module.
+
+ \qml
+ import QtQuick 2.0
+ import QtMultimedia 5.0
+
+ Text {
+ text: "Click Me!";
+ font.pointSize: 24;
+ width: 150; height: 50;
+
+ Audio {
+ id: playMusic
+ source: "music.wav"
+ }
+ MouseArea {
+ id: playArea
+ anchors.fill: parent
+ onPressed: { playMusic.play() }
+ }
+ }
+ \endqml
+
+ \sa Video
+*/
+
+/*!
+ \internal
+ \class QDeclarativeAudio
+ \brief The QDeclarativeAudio class provides an audio item that you can add to a QDeclarativeView.
+*/
+
+void QDeclarativeAudio_4::_q_error(int errorCode, const QString &errorString)
+{
+ m_error = QMediaPlayer::Error(errorCode);
+ m_errorString = errorString;
+
+ emit error(Error(errorCode), errorString);
+ emit errorChanged();
+}
+
+
+QDeclarativeAudio_4::QDeclarativeAudio_4(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QDeclarativeAudio_4::~QDeclarativeAudio_4()
+{
+ shutdown();
+}
+
+/*!
+ \qmlmethod Audio::play()
+
+ Starts playback of the media.
+
+ Sets the \l playing property to true, and the \l paused property to false.
+*/
+
+void QDeclarativeAudio_4::play()
+{
+ if (!m_complete)
+ return;
+
+ setPaused(false);
+ setPlaying(true);
+}
+
+/*!
+ \qmlmethod Audio::pause()
+
+ Pauses playback of the media.
+
+ Sets the \l playing and \l paused properties to true.
+*/
+
+void QDeclarativeAudio_4::pause()
+{
+ if (!m_complete)
+ return;
+
+ setPaused(true);
+ setPlaying(true);
+}
+
+/*!
+ \qmlmethod Audio::stop()
+
+ Stops playback of the media.
+
+ Sets the \l playing and \l paused properties to false.
+*/
+
+void QDeclarativeAudio_4::stop()
+{
+ if (!m_complete)
+ return;
+
+ setPlaying(false);
+ setPaused(false);
+}
+
+/*!
+ \qmlproperty url Audio::source
+
+ This property holds the source URL of the media.
+*/
+
+/*!
+ \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 Audio::playing
+
+ This property holds whether the media is playing.
+
+ Defaults to false, and can be set to true to start playback.
+*/
+
+/*!
+ \qmlproperty bool Audio::paused
+
+ This property holds whether the media is paused.
+
+ Defaults to false, and can be set to true to pause playback.
+*/
+
+/*!
+ \qmlsignal Audio::onStarted()
+
+ This handler is called when playback is started.
+*/
+
+/*!
+ \qmlsignal Audio::onResumed()
+
+ This handler is called when playback is resumed from the paused state.
+*/
+
+/*!
+ \qmlsignal Audio::onPaused()
+
+ This handler is called when playback is paused.
+*/
+
+/*!
+ \qmlsignal Audio::onStopped()
+
+ This handler is called when playback is stopped.
+*/
+
+/*!
+ \qmlproperty enumeration Audio::status
+
+ This property holds the status of media loading. It can be one of:
+
+ \list
+ \o NoMedia - no media has been set.
+ \o Loading - the media is currently being loaded.
+ \o Loaded - the media has been loaded.
+ \o Buffering - the media is buffering data.
+ \o Stalled - playback has been interrupted while the media is buffering data.
+ \o Buffered - the media has buffered data.
+ \o EndOfMedia - the media has played to the end.
+ \o InvalidMedia - the media cannot be played.
+ \o UnknownStatus - the status of the media is unknown.
+ \endlist
+*/
+
+QDeclarativeAudio_4::Status QDeclarativeAudio_4::status() const
+{
+ return Status(m_status);
+}
+
+/*!
+ \qmlproperty int Audio::duration
+
+ This property holds the duration of the media in milliseconds.
+
+ If the media doesn't have a fixed duration (a live stream for example) this will be 0.
+*/
+
+/*!
+ \qmlproperty int Audio::position
+
+ This property holds the current playback position in milliseconds.
+
+ If the \l seekable property is true, this property can be set to seek to a new position.
+*/
+
+/*!
+ \qmlproperty real Audio::volume
+
+ This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
+*/
+
+/*!
+ \qmlproperty bool Audio::muted
+
+ This property holds whether the audio output is muted.
+*/
+
+/*!
+ \qmlproperty bool Audio::hasAudio
+
+ This property holds whether the media contains audio.
+*/
+
+bool QDeclarativeAudio_4::hasAudio() const
+{
+ return !m_complete ? false : m_playerControl->isAudioAvailable();
+}
+
+/*!
+ \qmlproperty bool Audio::hasVideo
+
+ This property holds whether the media contains video.
+*/
+
+bool QDeclarativeAudio_4::hasVideo() const
+{
+ return !m_complete ? false : m_playerControl->isVideoAvailable();
+}
+
+/*!
+ \qmlproperty real Audio::bufferProgress
+
+ This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
+ (full).
+*/
+
+/*!
+ \qmlproperty bool Audio::seekable
+
+ This property holds whether position of the audio can be changed.
+
+ If true; setting a \l position value will cause playback to seek to the new position.
+*/
+
+/*!
+ \qmlproperty real Audio::playbackRate
+
+ This property holds the rate at which audio is played at as a multiple of the normal rate.
+*/
+
+/*!
+ \qmlproperty enumeration Audio::error
+
+ This property holds the error state of the audio. It can be one of:
+
+ \list
+ \o NoError - there is no current error.
+ \o ResourceError - the audio cannot be played due to a problem allocating resources.
+ \o FormatError - the audio format is not supported.
+ \o NetworkError - the audio cannot be played due to network issues.
+ \o AccessDenied - the audio cannot be played due to insufficient permissions.
+ \o ServiceMissing - the audio cannot be played because the media service could not be
+ instantiated.
+ \endlist
+*/
+
+QDeclarativeAudio_4::Error QDeclarativeAudio_4::error() const
+{
+ return Error(m_error);
+}
+
+void QDeclarativeAudio_4::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();
+}
+
+void QDeclarativeAudio_4::componentComplete()
+{
+ QDeclarativeMediaBase_4::componentComplete();
+}
+
+
+/*!
+ \qmlproperty string Audio::errorString
+
+ This property holds a string describing the current error condition in more detail.
+*/
+
+/*!
+ \qmlsignal Audio::onError(error, errorString)
+
+ This handler is called when an \l {QMediaPlayer::Error}{error} has
+ occurred. The errorString parameter may contain more detailed
+ information about the error.
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.title
+
+ This property holds the tile of the media.
+
+ \sa {QtMultimedia::MetaData::Title}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.subTitle
+
+ This property holds the sub-title of the media.
+
+ \sa {QtMultimedia::MetaData::SubTitle}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.author
+
+ This property holds the author of the media.
+
+ \sa {QtMultimedia::MetaData::Author}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.comment
+
+ This property holds a user comment about the media.
+
+ \sa {QtMultimedia::MetaData::Comment}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.description
+
+ This property holds a description of the media.
+
+ \sa {QtMultimedia::MetaData::Description}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.category
+
+ This property holds the category of the media
+
+ \sa {QtMultimedia::MetaData::Category}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.genre
+
+ This property holds the genre of the media.
+
+ \sa {QtMultimedia::MetaData::Genre}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.year
+
+ This property holds the year of release of the media.
+
+ \sa {QtMultimedia::MetaData::Year}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.date
+
+ This property holds the date of the media.
+
+ \sa {QtMultimedia::MetaData::Date}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.userRating
+
+ This property holds a user rating of the media in the range of 0 to 100.
+
+ \sa {QtMultimedia::MetaData::UserRating}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.keywords
+
+ This property holds a list of keywords describing the media.
+
+ \sa {QtMultimedia::MetaData::Keywords}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.language
+
+ This property holds the language of the media, as an ISO 639-2 code.
+
+ \sa {QtMultimedia::MetaData::Language}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.publisher
+
+ This property holds the publisher of the media.
+
+ \sa {QtMultimedia::MetaData::Publisher}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.copyright
+
+ This property holds the media's copyright notice.
+
+ \sa {QtMultimedia::MetaData::Copyright}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.parentalRating
+
+ This property holds the parental rating of the media.
+
+ \sa {QtMultimedia::MetaData::ParentalRating}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.ratingOrganization
+
+ This property holds the name of the rating organization responsible for the
+ parental rating of the media.
+
+ \sa {QtMultimedia::MetaData::RatingOrganization}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.size
+
+ This property property holds the size of the media in bytes.
+
+ \sa {QtMultimedia::MetaData::Size}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.mediaType
+
+ This property holds the type of the media.
+
+ \sa {QtMultimedia::MetaData::MediaType}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.audioBitRate
+
+ This property holds the bit rate of the media's audio stream ni bits per
+ second.
+
+ \sa {QtMultimedia::MetaData::AudioBitRate}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.audioCodec
+
+ This property holds the encoding of the media audio stream.
+
+ \sa {QtMultimedia::MetaData::AudioCodec}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.averageLevel
+
+ This property holds the average volume level of the media.
+
+ \sa {QtMultimedia::MetaData::AverageLevel}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.channelCount
+
+ This property holds the number of channels in the media's audio stream.
+
+ \sa {QtMultimedia::MetaData::ChannelCount}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.peakValue
+
+ This property holds the peak volume of media's audio stream.
+
+ \sa {QtMultimedia::MetaData::PeakValue}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.sampleRate
+
+ This property holds the sample rate of the media's audio stream in hertz.
+
+ \sa {QtMultimedia::MetaData::SampleRate}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.albumTitle
+
+ This property holds the title of the album the media belongs to.
+
+ \sa {QtMultimedia::MetaData::AlbumTitle}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.albumArtist
+
+ This property holds the name of the principal artist of the album the media
+ belongs to.
+
+ \sa {QtMultimedia::MetaData::AlbumArtist}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.contributingArtist
+
+ This property holds the names of artists contributing to the media.
+
+ \sa {QtMultimedia::MetaData::ContributingArtist}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.composer
+
+ This property holds the composer of the media.
+
+ \sa {QtMultimedia::MetaData::Composer}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.conductor
+
+ This property holds the conductor of the media.
+
+ \sa {QtMultimedia::MetaData::Conductor}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.lyrics
+
+ This property holds the lyrics to the media.
+
+ \sa {QtMultimedia::MetaData::Lyrics}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.mood
+
+ This property holds the mood of the media.
+
+ \sa {QtMultimedia::MetaData::Mood}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.trackNumber
+
+ This property holds the track number of the media.
+
+ \sa {QtMultimedia::MetaData::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.trackCount
+
+ This property holds the number of track on the album containing the media.
+
+ \sa {QtMultimedia::MetaData::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.coverArtUrlSmall
+
+ This property holds the URL of a small cover art image.
+
+ \sa {QtMultimedia::MetaData::CoverArtUrlSmall}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.coverArtUrlLarge
+
+ This property holds the URL of a large cover art image.
+
+ \sa {QtMultimedia::MetaData::CoverArtUrlLarge}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.resolution
+
+ This property holds the dimension of an image or video.
+
+ \sa {QtMultimedia::MetaData::Resolution}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.pixelAspectRatio
+
+ This property holds the pixel aspect ratio of an image or video.
+
+ \sa {QtMultimedia::MetaData::PixelAspectRatio}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.videoFrameRate
+
+ This property holds the frame rate of the media's video stream.
+
+ \sa {QtMultimedia::MetaData::VideoFrameRate}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.videoBitRate
+
+ This property holds the bit rate of the media's video stream in bits per
+ second.
+
+ \sa {QtMultimedia::MetaData::VideoBitRate}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.videoCodec
+
+ This property holds the encoding of the media's video stream.
+
+ \sa {QtMultimedia::MetaData::VideoCodec}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.posterUrl
+
+ This property holds the URL of a poster image.
+
+ \sa {QtMultimedia::MetaData::PosterUrl}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.chapterNumber
+
+ This property holds the chapter number of the media.
+
+ \sa {QtMultimedia::MetaData::ChapterNumber}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.director
+
+ This property holds the director of the media.
+
+ \sa {QtMultimedia::MetaData::Director}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.leadPerformer
+
+ This property holds the lead performer in the media.
+
+ \sa {QtMultimedia::MetaData::LeadPerformer}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.writer
+
+ This property holds the writer of the media.
+
+ \sa {QtMultimedia::MetaData::Writer}
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativeaudio_p_4.cpp"
+
+
diff --git a/src/imports/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h
index 5976015fa..942832894 100644
--- a/src/imports/multimedia/qdeclarativeaudio_p.h
+++ b/src/imports/multimedia/qdeclarativeaudio_p.h
@@ -69,10 +69,10 @@ class QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public Q
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
- Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged)
- Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(PlaybackState playbackState READ playbackState NOTIFY playbackStateChanged)
+ Q_PROPERTY(bool autoPlay READ autoPlay WRITE setAutoPlay NOTIFY autoPlayChanged)
+ Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
@@ -90,6 +90,7 @@ class QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public Q
Q_ENUMS(Status)
Q_ENUMS(Error)
Q_ENUMS(Loop)
+ Q_ENUMS(PlaybackState)
Q_INTERFACES(QDeclarativeParserStatus)
public:
enum Status
@@ -120,6 +121,13 @@ public:
Infinite = QDeclarativeMediaBase::INFINITE
};
+ enum PlaybackState
+ {
+ PlayingState = QMediaPlayer::PlayingState,
+ PausedState = QMediaPlayer::PausedState,
+ StoppedState = QMediaPlayer::StoppedState
+ };
+
QDeclarativeAudio(QObject *parent = 0);
~QDeclarativeAudio();
@@ -128,6 +136,7 @@ public:
Status status() const;
Error error() const;
+ PlaybackState playbackState() const;
void classBegin();
void componentComplete();
@@ -142,14 +151,14 @@ public Q_SLOTS:
Q_SIGNALS:
void sourceChanged();
void autoLoadChanged();
- void playingChanged();
- void pausedChanged();
void loopCountChanged();
- void started();
- void resumed();
+ void playbackStateChanged();
+ void autoPlayChanged();
+
void paused();
void stopped();
+ void playing();
void statusChanged();
diff --git a/src/imports/multimedia/qdeclarativeaudio_p_4.h b/src/imports/multimedia/qdeclarativeaudio_p_4.h
new file mode 100644
index 000000000..02c873df0
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativeaudio_p_4.h
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEAUDIO_4_P_H
+#define QDECLARATIVEAUDIO_4_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qbasictimer.h>
+#include <QtDeclarative/qdeclarativeparserstatus.h>
+#include <QtDeclarative/qdeclarative.h>
+
+#include "qdeclarativemediabase_p_4.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QTimerEvent;
+
+class QDeclarativeAudio_4 : public QObject, public QDeclarativeMediaBase_4, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
+ Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
+ 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)
+ Q_PROPERTY(Error error READ error NOTIFY errorChanged)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
+ Q_PROPERTY(QDeclarativeMediaMetaData *metaData READ metaData CONSTANT)
+ Q_PROPERTY(QObject *mediaObject READ mediaObject NOTIFY mediaObjectChanged SCRIPTABLE false DESIGNABLE false)
+ Q_ENUMS(Status)
+ Q_ENUMS(Error)
+ Q_ENUMS(Loop)
+ Q_INTERFACES(QDeclarativeParserStatus)
+public:
+ enum Status
+ {
+ UnknownStatus = QMediaPlayer::UnknownMediaStatus,
+ NoMedia = QMediaPlayer::NoMedia,
+ Loading = QMediaPlayer::LoadingMedia,
+ Loaded = QMediaPlayer::LoadedMedia,
+ Stalled = QMediaPlayer::StalledMedia,
+ Buffering = QMediaPlayer::BufferingMedia,
+ Buffered = QMediaPlayer::BufferedMedia,
+ EndOfMedia = QMediaPlayer::EndOfMedia,
+ InvalidMedia = QMediaPlayer::InvalidMedia
+ };
+
+ enum Error
+ {
+ NoError = QMediaPlayer::NoError,
+ ResourceError = QMediaPlayer::ResourceError,
+ FormatError = QMediaPlayer::FormatError,
+ NetworkError = QMediaPlayer::NetworkError,
+ AccessDenied = QMediaPlayer::AccessDeniedError,
+ ServiceMissing = QMediaPlayer::ServiceMissingError
+ };
+
+ enum Loop
+ {
+ Infinite = QDeclarativeMediaBase_4::INFINITE
+ };
+
+ QDeclarativeAudio_4(QObject *parent = 0);
+ ~QDeclarativeAudio_4();
+
+ bool hasAudio() const;
+ bool hasVideo() const;
+
+ Status status() const;
+ Error error() const;
+
+ void classBegin();
+ void componentComplete();
+
+ QObject *mediaObject() { return m_mediaObject; }
+
+public Q_SLOTS:
+ void play();
+ void pause();
+ void stop();
+
+Q_SIGNALS:
+ void sourceChanged();
+ void autoLoadChanged();
+ void playingChanged();
+ void pausedChanged();
+ void loopCountChanged();
+
+ void started();
+ void resumed();
+ void paused();
+ void stopped();
+
+ void statusChanged();
+
+ void durationChanged();
+ void positionChanged();
+
+ void volumeChanged();
+ void mutedChanged();
+ void hasAudioChanged();
+ void hasVideoChanged();
+
+ void bufferProgressChanged();
+
+ void seekableChanged();
+ void playbackRateChanged();
+
+ void errorChanged();
+ void error(QDeclarativeAudio_4::Error error, const QString &errorString);
+
+ void mediaObjectChanged();
+
+private Q_SLOTS:
+ void _q_error(int, const QString &);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeAudio_4)
+ Q_PRIVATE_SLOT(mediaBase(), void _q_statusChanged())
+
+ inline QDeclarativeMediaBase_4 *mediaBase() { return this; }
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio_4))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativemediabase.cpp b/src/imports/multimedia/qdeclarativemediabase.cpp
index 593afea36..a1f80f2b4 100644
--- a/src/imports/multimedia/qdeclarativemediabase.cpp
+++ b/src/imports/multimedia/qdeclarativemediabase.cpp
@@ -130,7 +130,7 @@ protected:
if (event->timerId() == m_timer.timerId()) {
event->accept();
- if (m_media->m_playing && !m_media->m_paused)
+ if (m_media->m_playbackState == QMediaPlayer::PlayingState)
emit m_media->positionChanged();
if (m_media->m_status == QMediaPlayer::BufferingMedia || QMediaPlayer::StalledMedia)
emit m_media->bufferProgressChanged();
@@ -150,63 +150,40 @@ void QDeclarativeMediaBase::_q_statusChanged()
m_runningCount -= 1;
m_playerControl->play();
}
-
const QMediaPlayer::MediaStatus oldStatus = m_status;
- const bool wasPlaying = m_playing;
- const bool wasPaused = m_paused;
+ const QMediaPlayer::State lastPlaybackState = m_playbackState;
const QMediaPlayer::State state = m_playerControl->state();
- m_status = m_playerControl->mediaStatus();
-
- if (m_complete)
- m_playing = state != QMediaPlayer::StoppedState;
+ m_playbackState = state;
- if (state == QMediaPlayer::PausedState)
- m_paused = true;
- else if (state == QMediaPlayer::PlayingState)
- m_paused = false;
+ m_status = m_playerControl->mediaStatus();
if (m_status != oldStatus)
emit statusChanged();
- switch (state) {
- case QMediaPlayer::StoppedState:
- if (wasPlaying) {
- emit stopped();
+ if (lastPlaybackState != state) {
- if (!m_playing)
- emit playingChanged();
- }
- break;
- case QMediaPlayer::PausedState:
- if (!wasPlaying) {
- emit started();
- if (m_playing)
- emit playingChanged();
- }
- if ((!wasPaused || !wasPlaying) && m_paused)
+ if (lastPlaybackState == QMediaPlayer::StoppedState)
+ m_runningCount = m_loopCount - 1;
+
+ switch (state) {
+ case QMediaPlayer::StoppedState:
+ emit stopped();
+ break;
+ case QMediaPlayer::PausedState:
emit paused();
- if (!wasPaused && m_paused)
- emit pausedChanged();
-
- break;
-
- case QMediaPlayer::PlayingState:
- if (wasPaused && wasPlaying)
- emit resumed();
- else
- emit started();
-
- if (wasPaused && !m_paused)
- emit pausedChanged();
- if (!wasPlaying && m_playing)
- emit playingChanged();
- break;
+ break;
+ case QMediaPlayer::PlayingState:
+ emit playing();
+ break;
+ }
+
+ emit playbackStateChanged();
}
// Check
- if ((m_playing && !m_paused)
+ if ((state == QMediaPlayer::PlayingState)
|| m_status == QMediaPlayer::BufferingMedia
|| m_status == QMediaPlayer::StalledMedia) {
m_animation->start();
@@ -217,8 +194,7 @@ void QDeclarativeMediaBase::_q_statusChanged()
}
QDeclarativeMediaBase::QDeclarativeMediaBase()
- : m_paused(false)
- , m_playing(false)
+ : m_autoPlay(false)
, m_autoLoad(true)
, m_loaded(false)
, m_muted(false)
@@ -235,6 +211,7 @@ QDeclarativeMediaBase::QDeclarativeMediaBase()
, m_mediaProvider(0)
, m_metaDataControl(0)
, m_animation(0)
+ , m_playbackState(QMediaPlayer::StoppedState)
, m_status(QMediaPlayer::NoMedia)
, m_error(QMediaPlayer::ServiceMissingError)
{
@@ -319,21 +296,18 @@ void QDeclarativeMediaBase::componentComplete()
if (!qFuzzyCompare(m_playbackRate, qreal(1.0)))
m_playerControl->setPlaybackRate(m_playbackRate);
- if (!m_source.isEmpty() && (m_autoLoad || m_playing)) // Override autoLoad if playing set
+ if (!m_source.isEmpty() && (m_autoLoad || m_autoPlay)) {
m_playerControl->setMedia(m_source, 0);
-
- m_complete = true;
-
- if (m_playing) {
+ m_loaded = true;
if (m_position > 0)
m_playerControl->setPosition(m_position);
+ }
- if (m_source.isEmpty()) {
- m_playing = false;
+ m_complete = true;
- emit playingChanged();
- } else if (m_paused) {
- m_playerControl->pause();
+ if (m_autoPlay) {
+ if (m_source.isEmpty()) {
+ m_playerControl->stop();
} else {
m_playerControl->play();
}
@@ -347,6 +321,21 @@ QUrl QDeclarativeMediaBase::source() const
return m_source;
}
+bool QDeclarativeMediaBase::autoPlay() const
+{
+ return m_autoPlay;
+}
+
+void QDeclarativeMediaBase::setAutoPlay(bool autoplay)
+{
+ if (m_autoPlay == autoplay)
+ return;
+
+ m_autoPlay = autoplay;
+ emit autoPlayChanged();
+}
+
+
void QDeclarativeMediaBase::setSource(const QUrl &url)
{
if (url == m_source)
@@ -354,7 +343,7 @@ void QDeclarativeMediaBase::setSource(const QUrl &url)
m_source = url;
m_loaded = false;
- if (m_complete && (m_autoLoad || url.isEmpty())) {
+ if (m_complete && (m_autoLoad || url.isEmpty() || m_autoPlay)) {
if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
m_error = QMediaPlayer::NoError;
m_errorString = QString();
@@ -367,6 +356,8 @@ void QDeclarativeMediaBase::setSource(const QUrl &url)
}
else
emit sourceChanged();
+
+ if (m_autoPlay) m_playerControl->play();
}
bool QDeclarativeMediaBase::isAutoLoad() const
@@ -399,68 +390,46 @@ void QDeclarativeMediaBase::setLoopCount(int loopCount)
return;
}
m_loopCount = loopCount;
+ m_runningCount = loopCount - 1;
emit loopCountChanged();
}
-bool QDeclarativeMediaBase::isPlaying() const
-{
- return m_playing;
-}
-
-void QDeclarativeMediaBase::setPlaying(bool playing)
+void QDeclarativeMediaBase::setPlaybackState(QMediaPlayer::State playbackState)
{
- if (playing == m_playing)
+ if (m_playbackState == playbackState)
return;
if (m_complete) {
- if (playing) {
- if (!m_autoLoad && !m_loaded) {
+ switch (playbackState){
+ case (QMediaPlayer::PlayingState):
+ if (!m_loaded) {
m_playerControl->setMedia(m_source, 0);
m_playerControl->setPosition(m_position);
m_loaded = true;
}
+ m_playerControl->play();
+ break;
- m_runningCount = m_loopCount - 1;
+ case (QMediaPlayer::PausedState):
+ if (!m_loaded) {
+ m_playerControl->setMedia(m_source, 0);
+ m_playerControl->setPosition(m_position);
+ m_loaded = true;
+ }
+ m_playerControl->pause();
+ break;
- if (!m_paused)
- m_playerControl->play();
- else
- m_playerControl->pause();
- } else {
+ case (QMediaPlayer::StoppedState):
m_playerControl->stop();
}
- } else {
- m_playing = playing;
- emit playingChanged();
}
}
-bool QDeclarativeMediaBase::isPaused() const
+QMediaPlayer::State QDeclarativeMediaBase::playbackState() const
{
- return m_paused;
+ return m_playbackState;
}
-void QDeclarativeMediaBase::setPaused(bool paused)
-{
- if (m_paused == paused)
- return;
-
- if (m_complete && m_playing) {
- if (!m_autoLoad && !m_loaded) {
- m_playerControl->setMedia(m_source, 0);
- m_playerControl->setPosition(m_position);
- m_loaded = true;
- }
-
- if (!paused)
- m_playerControl->play();
- else
- m_playerControl->pause();
- } else {
- m_paused = paused;
- emit pausedChanged();
- }
-}
int QDeclarativeMediaBase::duration() const
{
diff --git a/src/imports/multimedia/qdeclarativemediabase_4.cpp b/src/imports/multimedia/qdeclarativemediabase_4.cpp
new file mode 100644
index 000000000..dee5c0c45
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativemediabase_4.cpp
@@ -0,0 +1,567 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativemediabase_p_4.h"
+
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qurl.h>
+#include <QtDeclarative/qdeclarativeinfo.h>
+
+#include <qmediaplayercontrol.h>
+#include <qmediaservice.h>
+#include <private/qmediaserviceprovider_p.h>
+#include <qmetadatareadercontrol.h>
+
+#include "qdeclarativemediametadata_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+class QDeclarativeMediaBaseObject : public QMediaObject
+{
+public:
+ QDeclarativeMediaBaseObject(QMediaService *service)
+ : QMediaObject(0, service)
+ {
+ }
+};
+
+class QDeclarativeMediaBasePlayerControl : public QMediaPlayerControl
+{
+public:
+ QDeclarativeMediaBasePlayerControl(QObject *parent)
+ : QMediaPlayerControl(parent)
+ {
+ }
+
+ QMediaPlayer::State state() const { return QMediaPlayer::StoppedState; }
+ QMediaPlayer::MediaStatus mediaStatus() const { return QMediaPlayer::NoMedia; }
+
+ qint64 duration() const { return 0; }
+ qint64 position() const { return 0; }
+ void setPosition(qint64) {}
+ int volume() const { return 0; }
+ void setVolume(int) {}
+ bool isMuted() const { return false; }
+ void setMuted(bool) {}
+ int bufferStatus() const { return 0; }
+ bool isAudioAvailable() const { return false; }
+ bool isVideoAvailable() const { return false; }
+ bool isSeekable() const { return false; }
+ QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
+ qreal playbackRate() const { return 1; }
+ void setPlaybackRate(qreal) {}
+ QMediaContent media() const { return QMediaContent(); }
+ const QIODevice *mediaStream() const { return 0; }
+ void setMedia(const QMediaContent &, QIODevice *) {}
+
+ void play() {}
+ void pause() {}
+ void stop() {}
+};
+
+
+class QDeclarativeMediaBaseMetaDataControl : public QMetaDataReaderControl
+{
+public:
+ QDeclarativeMediaBaseMetaDataControl(QObject *parent)
+ : QMetaDataReaderControl(parent)
+ {
+ }
+
+ bool isMetaDataAvailable() const { return false; }
+
+ QVariant metaData(const QString &) const { return QVariant(); }
+ QStringList availableMetaData() const { return QStringList(); }
+};
+
+class QDeclarativeMediaBaseAnimation : public QObject
+{
+public:
+ QDeclarativeMediaBaseAnimation(QDeclarativeMediaBase_4 *media)
+ : m_media(media)
+ {
+ }
+
+ void start() { if (!m_timer.isActive()) m_timer.start(500, this); }
+ void stop() { m_timer.stop(); }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == m_timer.timerId()) {
+ event->accept();
+
+ if (m_media->m_playing && !m_media->m_paused)
+ emit m_media->positionChanged();
+ if (m_media->m_status == QMediaPlayer::BufferingMedia || QMediaPlayer::StalledMedia)
+ emit m_media->bufferProgressChanged();
+ } else {
+ QObject::timerEvent(event);
+ }
+ }
+
+private:
+ QDeclarativeMediaBase_4 *m_media;
+ QBasicTimer m_timer;
+};
+
+void QDeclarativeMediaBase_4::_q_statusChanged()
+{
+ if (m_playerControl->mediaStatus() == QMediaPlayer::EndOfMedia && m_runningCount != 0) {
+ m_runningCount -= 1;
+ m_playerControl->play();
+ }
+
+ const QMediaPlayer::MediaStatus oldStatus = m_status;
+ const bool wasPlaying = m_playing;
+ const bool wasPaused = m_paused;
+
+ const QMediaPlayer::State state = m_playerControl->state();
+
+ m_status = m_playerControl->mediaStatus();
+
+ if (m_complete)
+ m_playing = state != QMediaPlayer::StoppedState;
+
+ if (state == QMediaPlayer::PausedState)
+ m_paused = true;
+ else if (state == QMediaPlayer::PlayingState)
+ m_paused = false;
+
+ if (m_status != oldStatus)
+ emit statusChanged();
+
+ switch (state) {
+ case QMediaPlayer::StoppedState:
+ if (wasPlaying) {
+ emit stopped();
+
+ if (!m_playing)
+ emit playingChanged();
+ }
+ break;
+ case QMediaPlayer::PausedState:
+ if (!wasPlaying) {
+ emit started();
+ if (m_playing)
+ emit playingChanged();
+ }
+ if ((!wasPaused || !wasPlaying) && m_paused)
+ emit paused();
+ if (!wasPaused && m_paused)
+ emit pausedChanged();
+
+ break;
+
+ case QMediaPlayer::PlayingState:
+ if (wasPaused && wasPlaying)
+ emit resumed();
+ else
+ emit started();
+
+ if (wasPaused && !m_paused)
+ emit pausedChanged();
+ if (!wasPlaying && m_playing)
+ emit playingChanged();
+ break;
+ }
+
+ // Check
+ if ((m_playing && !m_paused)
+ || m_status == QMediaPlayer::BufferingMedia
+ || m_status == QMediaPlayer::StalledMedia) {
+ m_animation->start();
+ }
+ else {
+ m_animation->stop();
+ }
+}
+
+QDeclarativeMediaBase_4::QDeclarativeMediaBase_4()
+ : m_paused(false)
+ , m_playing(false)
+ , m_autoLoad(true)
+ , m_loaded(false)
+ , m_muted(false)
+ , m_complete(false)
+ , m_loopCount(1)
+ , m_runningCount(0)
+ , m_position(0)
+ , m_vol(1.0)
+ , m_playbackRate(1.0)
+ , m_mediaService(0)
+ , m_playerControl(0)
+ , m_qmlObject(0)
+ , m_mediaObject(0)
+ , m_mediaProvider(0)
+ , m_metaDataControl(0)
+ , m_animation(0)
+ , m_status(QMediaPlayer::NoMedia)
+ , m_error(QMediaPlayer::ServiceMissingError)
+{
+}
+
+QDeclarativeMediaBase_4::~QDeclarativeMediaBase_4()
+{
+}
+
+void QDeclarativeMediaBase_4::shutdown()
+{
+ delete m_mediaObject;
+ m_metaData.reset();
+
+ if (m_mediaProvider)
+ m_mediaProvider->releaseService(m_mediaService);
+
+ delete m_animation;
+
+}
+
+void QDeclarativeMediaBase_4::setObject(QObject *object, const QByteArray &type)
+{
+ m_qmlObject = object;
+
+ if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider()) != 0) {
+ m_mediaService = m_mediaProvider->requestService(type);
+ if (m_mediaService != 0) {
+ m_playerControl = qobject_cast<QMediaPlayerControl *>(
+ m_mediaService->requestControl(QMediaPlayerControl_iid));
+ m_metaDataControl = qobject_cast<QMetaDataReaderControl *>(
+ m_mediaService->requestControl(QMetaDataReaderControl_iid));
+ m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService);
+ }
+ }
+
+ if (m_playerControl) {
+ QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)),
+ object, SLOT(_q_statusChanged()));
+ QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
+ object, SLOT(_q_statusChanged()));
+ QObject::connect(m_playerControl, SIGNAL(mediaChanged(QMediaContent)),
+ object, SIGNAL(sourceChanged()));
+ QObject::connect(m_playerControl, SIGNAL(durationChanged(qint64)),
+ object, SIGNAL(durationChanged()));
+ QObject::connect(m_playerControl, SIGNAL(positionChanged(qint64)),
+ object, SIGNAL(positionChanged()));
+ QObject::connect(m_playerControl, SIGNAL(volumeChanged(int)),
+ object, SIGNAL(volumeChanged()));
+ QObject::connect(m_playerControl, SIGNAL(mutedChanged(bool)),
+ object, SIGNAL(mutedChanged()));
+ QObject::connect(m_playerControl, SIGNAL(bufferStatusChanged(int)),
+ object, SIGNAL(bufferProgressChanged()));
+ QObject::connect(m_playerControl, SIGNAL(seekableChanged(bool)),
+ object, SIGNAL(seekableChanged()));
+ QObject::connect(m_playerControl, SIGNAL(playbackRateChanged(qreal)),
+ object, SIGNAL(playbackRateChanged()));
+ QObject::connect(m_playerControl, SIGNAL(error(int,QString)),
+ object, SLOT(_q_error(int,QString)));
+
+ m_animation = new QDeclarativeMediaBaseAnimation(this);
+ m_error = QMediaPlayer::NoError;
+ } else {
+ m_playerControl = new QDeclarativeMediaBasePlayerControl(object);
+ }
+
+ if (!m_metaDataControl)
+ m_metaDataControl = new QDeclarativeMediaBaseMetaDataControl(object);
+
+ m_metaData.reset(new QDeclarativeMediaMetaData(m_metaDataControl));
+
+ QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()),
+ m_metaData.data(), SIGNAL(metaDataChanged()));
+}
+
+void QDeclarativeMediaBase_4::componentComplete()
+{
+ if (!qFuzzyCompare(m_vol, qreal(1.0)))
+ m_playerControl->setVolume(m_vol * 100);
+ if (m_muted)
+ m_playerControl->setMuted(m_muted);
+ if (!qFuzzyCompare(m_playbackRate, qreal(1.0)))
+ m_playerControl->setPlaybackRate(m_playbackRate);
+
+ if (!m_source.isEmpty() && (m_autoLoad || m_playing)) // Override autoLoad if playing set
+ m_playerControl->setMedia(m_source, 0);
+
+ m_complete = true;
+
+ if (m_playing) {
+ if (m_position > 0)
+ m_playerControl->setPosition(m_position);
+
+ if (m_source.isEmpty()) {
+ m_playing = false;
+
+ emit playingChanged();
+ } else if (m_paused) {
+ m_playerControl->pause();
+ } else {
+ m_playerControl->play();
+ }
+ }
+}
+
+// Properties
+
+QUrl QDeclarativeMediaBase_4::source() const
+{
+ return m_source;
+}
+
+void QDeclarativeMediaBase_4::setSource(const QUrl &url)
+{
+ if (url == m_source)
+ return;
+
+ m_source = url;
+ m_loaded = false;
+ if (m_complete && (m_autoLoad || url.isEmpty())) {
+ if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
+ m_error = QMediaPlayer::NoError;
+ m_errorString = QString();
+
+ emit errorChanged();
+ }
+
+ m_playerControl->setMedia(m_source, 0);
+ m_loaded = true;
+ }
+ else
+ emit sourceChanged();
+}
+
+bool QDeclarativeMediaBase_4::isAutoLoad() const
+{
+ return m_autoLoad;
+}
+
+void QDeclarativeMediaBase_4::setAutoLoad(bool autoLoad)
+{
+ if (m_autoLoad == autoLoad)
+ return;
+
+ m_autoLoad = autoLoad;
+ emit autoLoadChanged();
+}
+
+int QDeclarativeMediaBase_4::loopCount() const
+{
+ return m_loopCount;
+}
+
+void QDeclarativeMediaBase_4::setLoopCount(int loopCount)
+{
+ if (loopCount == 0)
+ loopCount = 1;
+ else if (loopCount < -1)
+ loopCount = -1;
+
+ if (m_loopCount == loopCount) {
+ return;
+ }
+ m_loopCount = loopCount;
+ emit loopCountChanged();
+}
+
+bool QDeclarativeMediaBase_4::isPlaying() const
+{
+ return m_playing;
+}
+
+void QDeclarativeMediaBase_4::setPlaying(bool playing)
+{
+ if (playing == m_playing)
+ return;
+
+ if (m_complete) {
+ if (playing) {
+ if (!m_autoLoad && !m_loaded) {
+ m_playerControl->setMedia(m_source, 0);
+ m_playerControl->setPosition(m_position);
+ m_loaded = true;
+ }
+
+ m_runningCount = m_loopCount - 1;
+
+ if (!m_paused)
+ m_playerControl->play();
+ else
+ m_playerControl->pause();
+ } else {
+ m_playerControl->stop();
+ }
+ } else {
+ m_playing = playing;
+ emit playingChanged();
+ }
+}
+
+bool QDeclarativeMediaBase_4::isPaused() const
+{
+ return m_paused;
+}
+
+void QDeclarativeMediaBase_4::setPaused(bool paused)
+{
+ if (m_paused == paused)
+ return;
+
+ if (m_complete && m_playing) {
+ if (!m_autoLoad && !m_loaded) {
+ m_playerControl->setMedia(m_source, 0);
+ m_playerControl->setPosition(m_position);
+ m_loaded = true;
+ }
+
+ if (!paused)
+ m_playerControl->play();
+ else
+ m_playerControl->pause();
+ } else {
+ m_paused = paused;
+ emit pausedChanged();
+ }
+}
+
+int QDeclarativeMediaBase_4::duration() const
+{
+ return !m_complete ? 0 : m_playerControl->duration();
+}
+
+int QDeclarativeMediaBase_4::position() const
+{
+ return !m_complete ? m_position : m_playerControl->position();
+}
+
+void QDeclarativeMediaBase_4::setPosition(int position)
+{
+ if (this->position() == position)
+ return;
+
+ m_position = position;
+ if (m_complete)
+ m_playerControl->setPosition(m_position);
+ else
+ emit positionChanged();
+}
+
+qreal QDeclarativeMediaBase_4::volume() const
+{
+ return !m_complete ? m_vol : qreal(m_playerControl->volume()) / 100;
+}
+
+void QDeclarativeMediaBase_4::setVolume(qreal volume)
+{
+ if (volume < 0 || volume > 1) {
+ qmlInfo(m_qmlObject) << m_qmlObject->tr("volume should be between 0.0 and 1.0");
+ return;
+ }
+
+ if (m_vol == volume)
+ return;
+
+ m_vol = volume;
+
+ if (m_complete)
+ m_playerControl->setVolume(qRound(volume * 100));
+ else
+ emit volumeChanged();
+}
+
+bool QDeclarativeMediaBase_4::isMuted() const
+{
+ return !m_complete ? m_muted : m_playerControl->isMuted();
+}
+
+void QDeclarativeMediaBase_4::setMuted(bool muted)
+{
+ if (m_muted == muted)
+ return;
+
+ m_muted = muted;
+
+ if (m_complete)
+ m_playerControl->setMuted(muted);
+ else
+ emit mutedChanged();
+}
+
+qreal QDeclarativeMediaBase_4::bufferProgress() const
+{
+ return !m_complete ? 0 : qreal(m_playerControl->bufferStatus()) / 100;
+}
+
+bool QDeclarativeMediaBase_4::isSeekable() const
+{
+ return !m_complete ? false : m_playerControl->isSeekable();
+}
+
+qreal QDeclarativeMediaBase_4::playbackRate() const
+{
+ return m_playbackRate;
+}
+
+void QDeclarativeMediaBase_4::setPlaybackRate(qreal rate)
+{
+ if (m_playbackRate == rate)
+ return;
+
+ m_playbackRate = rate;
+
+ if (m_complete)
+ m_playerControl->setPlaybackRate(m_playbackRate);
+ else
+ emit playbackRateChanged();
+}
+
+QString QDeclarativeMediaBase_4::errorString() const
+{
+ return m_errorString;
+}
+
+QDeclarativeMediaMetaData *QDeclarativeMediaBase_4::metaData() const
+{
+ return m_metaData.data();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/imports/multimedia/qdeclarativemediabase_p.h b/src/imports/multimedia/qdeclarativemediabase_p.h
index 9df5db1ce..78c3524e2 100644
--- a/src/imports/multimedia/qdeclarativemediabase_p.h
+++ b/src/imports/multimedia/qdeclarativemediabase_p.h
@@ -81,17 +81,11 @@ public:
QUrl source() const;
void setSource(const QUrl &url);
- bool isAutoLoad() const;
- void setAutoLoad(bool autoLoad);
-
int loopCount() const;
void setLoopCount(int loopCount);
- bool isPlaying() const;
- void setPlaying(bool playing);
-
- bool isPaused() const;
- void setPaused(bool paused);
+ QMediaPlayer::State playbackState() const;
+ void setPlaybackState(QMediaPlayer::State playbackState);
int duration() const;
@@ -121,21 +115,27 @@ public:
void componentComplete();
+ bool isAutoLoad() const;
+ void setAutoLoad(bool autoLoad);
+
+ bool autoPlay() const;
+ void setAutoPlay(bool autoplay);
+
protected:
void shutdown();
void setObject(QObject *object, const QByteArray &type = Q_MEDIASERVICE_MEDIAPLAYER);
virtual void sourceChanged() = 0;
- virtual void autoLoadChanged() = 0;
- virtual void playingChanged() = 0;
- virtual void pausedChanged() = 0;
virtual void loopCountChanged() = 0;
- virtual void started() = 0;
- virtual void resumed() = 0;
virtual void paused() = 0;
virtual void stopped() = 0;
+ virtual void playing() = 0;
+
+ virtual void autoLoadChanged() = 0;
+
+ virtual void playbackStateChanged() = 0;
virtual void statusChanged() = 0;
@@ -152,8 +152,9 @@ protected:
virtual void errorChanged() = 0;
- bool m_paused;
- bool m_playing;
+ virtual void autoPlayChanged() = 0;
+
+ bool m_autoPlay;
bool m_autoLoad;
bool m_loaded;
bool m_muted;
@@ -173,6 +174,7 @@ protected:
QDeclarativeMediaBaseAnimation *m_animation;
QScopedPointer<QDeclarativeMediaMetaData> m_metaData;
+ QMediaPlayer::State m_playbackState;
QMediaPlayer::MediaStatus m_status;
QMediaPlayer::Error m_error;
QString m_errorString;
diff --git a/src/imports/multimedia/qdeclarativemediabase_p_4.h b/src/imports/multimedia/qdeclarativemediabase_p_4.h
new file mode 100644
index 000000000..fab555b93
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativemediabase_p_4.h
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMEDIABASE_4_P_H
+#define QDECLARATIVEMEDIABASE_4_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qbasictimer.h>
+#include <qmediaplayer.h>
+#include <private/qmediaserviceprovider_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QMediaPlayerControl;
+class QMediaService;
+class QMediaServiceProvider;
+class QMetaDataReaderControl;
+class QDeclarativeMediaBaseAnimation;
+class QDeclarativeMediaMetaData;
+
+class QDeclarativeMediaBase_4
+{
+public:
+ enum Loop {
+ INFINITE = -1
+ };
+
+ QDeclarativeMediaBase_4();
+ virtual ~QDeclarativeMediaBase_4();
+
+ QUrl source() const;
+ void setSource(const QUrl &url);
+
+ bool isAutoLoad() const;
+ void setAutoLoad(bool autoLoad);
+
+ int loopCount() const;
+ void setLoopCount(int loopCount);
+
+ bool isPlaying() const;
+ void setPlaying(bool playing);
+
+ bool isPaused() const;
+ void setPaused(bool paused);
+
+ int duration() const;
+
+ int position() const;
+ void setPosition(int position);
+
+ qreal volume() const;
+ void setVolume(qreal volume);
+
+ bool isMuted() const;
+ void setMuted(bool muted);
+
+ qreal bufferProgress() const;
+
+ bool isSeekable() const;
+
+ qreal playbackRate() const;
+ void setPlaybackRate(qreal rate);
+
+ QString errorString() const;
+
+ QDeclarativeMediaMetaData *metaData() const;
+
+ void _q_statusChanged();
+
+ void _q_metaDataChanged();
+
+ void componentComplete();
+
+protected:
+ void shutdown();
+
+ void setObject(QObject *object, const QByteArray &type = Q_MEDIASERVICE_MEDIAPLAYER);
+
+ virtual void sourceChanged() = 0;
+ virtual void autoLoadChanged() = 0;
+ virtual void playingChanged() = 0;
+ virtual void pausedChanged() = 0;
+ virtual void loopCountChanged() = 0;
+
+ virtual void started() = 0;
+ virtual void resumed() = 0;
+ virtual void paused() = 0;
+ virtual void stopped() = 0;
+
+ virtual void statusChanged() = 0;
+
+ virtual void durationChanged() = 0;
+ virtual void positionChanged() = 0;
+
+ virtual void volumeChanged() = 0;
+ virtual void mutedChanged() = 0;
+
+ virtual void bufferProgressChanged() = 0;
+
+ virtual void seekableChanged() = 0;
+ virtual void playbackRateChanged() = 0;
+
+ virtual void errorChanged() = 0;
+
+ bool m_paused;
+ bool m_playing;
+ bool m_autoLoad;
+ bool m_loaded;
+ bool m_muted;
+ bool m_complete;
+ int m_loopCount;
+ int m_runningCount;
+ int m_position;
+ qreal m_vol;
+ qreal m_playbackRate;
+ QMediaService *m_mediaService;
+ QMediaPlayerControl *m_playerControl;
+
+ QObject *m_qmlObject;
+ QMediaObject *m_mediaObject;
+ QMediaServiceProvider *m_mediaProvider;
+ QMetaDataReaderControl *m_metaDataControl;
+ QDeclarativeMediaBaseAnimation *m_animation;
+ QScopedPointer<QDeclarativeMediaMetaData> m_metaData;
+
+ QMediaPlayer::MediaStatus m_status;
+ QMediaPlayer::Error m_error;
+ QString m_errorString;
+ QUrl m_source;
+
+ friend class QDeclarativeMediaBaseAnimation;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir
index 369d6a651..739b33f67 100644
--- a/src/imports/multimedia/qmldir
+++ b/src/imports/multimedia/qmldir
@@ -1,2 +1,3 @@
plugin declarative_multimedia
Video 5.0 Video.qml
+Video 4.0 Video_4.qml