From a94c8a1ac26f4a5a79d63672d21538d016bc09f4 Mon Sep 17 00:00:00 2001 From: Angus Cummings Date: Fri, 3 Feb 2012 11:49:47 +1000 Subject: 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 Reviewed-by: Dmytro Poplavskiy --- src/imports/multimedia/qdeclarativeaudio.cpp | 72 +++++++++++++++------------- 1 file changed, 40 insertions(+), 32 deletions(-) (limited to 'src/imports/multimedia/qdeclarativeaudio.cpp') 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 -- cgit v1.2.3