From c88abd01775ea26f9552b89694ffb95b770af407 Mon Sep 17 00:00:00 2001 From: Michael Goddard Date: Tue, 12 Jun 2012 17:18:03 +1000 Subject: Replace a writable position() property with a seek() method. Seeking is sometimes asynchronous, and more importantly nearly every one using a slider for seeking ends up with a binding loop. Change-Id: I45d92e19b0276c8b97c51c073754d1c9d3dc611e Reviewed-by: Ling Hu --- src/imports/multimedia/qdeclarativeaudio.cpp | 69 +++++++++++++++++++--------- 1 file changed, 48 insertions(+), 21 deletions(-) (limited to 'src/imports/multimedia/qdeclarativeaudio.cpp') diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 97aac507b..39790c6f4 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -276,23 +276,6 @@ int QDeclarativeAudio::position() const return !m_complete ? m_position : m_player->position(); } -void QDeclarativeAudio::setPosition(int position) -{ - // QMediaPlayer clamps this to positive numbers - if (position < 0) - position = 0; - - if (this->position() == position) - return; - - m_position = position; - - if (m_complete) - m_player->setPosition(m_position); - else - emit positionChanged(); -} - qreal QDeclarativeAudio::volume() const { return !m_complete ? m_vol : qreal(m_player->volume()) / 100; @@ -421,6 +404,34 @@ void QDeclarativeAudio::stop() setPlaybackState(QMediaPlayer::StoppedState); } +/*! + \qmlmethod QtMultimedia5::Audio::seek(offset) + + If the \l seekable property is true, seeks the current + playback position to \a offset. + + Seeking may be asynchronous, so the \l position property + may not be updated immediately. + + \sa seekable, position +*/ +void QDeclarativeAudio::seek(int position) +{ + // QMediaPlayer clamps this to positive numbers + if (position < 0) + position = 0; + + if (this->position() == position) + return; + + m_position = position; + + if (m_complete) + m_player->setPosition(m_position); + else + emit positionChanged(); +} + /*! \qmlproperty url QtMultimedia5::Audio::source @@ -522,7 +533,9 @@ QDeclarativeAudio::PlaybackState QDeclarativeAudio::playbackState() const 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. + To change this position, use the \l seek() method. + + \sa seek() */ /*! @@ -575,7 +588,7 @@ bool QDeclarativeAudio::hasVideo() const 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. + If true, calling the \l seek() method will cause playback to seek to the new position. */ /*! @@ -1321,7 +1334,9 @@ void QDeclarativeAudio::_q_statusChanged() 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. + To change this position, use the \l seek() method. + + \sa seek() */ /*! @@ -1364,7 +1379,19 @@ void QDeclarativeAudio::_q_statusChanged() 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. + If true, calling the \l seek() method will cause playback to seek to the new position. +*/ + +/*! + \qmlmethod QtMultimedia5::MediaPlayer::seek(offset) + + If the \l seekable property is true, seeks the current + playback position to \a offset. + + Seeking may be asynchronous, so the \l position property + may not be updated immediately. + + \sa seekable, position */ /*! -- cgit v1.2.3