diff options
author | Joni Poikelin <joni.poikelin@theqtcompany.com> | 2016-04-15 18:35:33 +0300 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@qt.io> | 2016-09-07 12:48:40 +0000 |
commit | 62f1899a23b456f03cfccfaefcdf670d3cbb0f35 (patch) | |
tree | 236543eb24917fe4e153567a20b46dbd6a8ef612 /src/imports/multimedia/qdeclarativeaudio.cpp | |
parent | 2d1c728c4c4522d0e405da514b6ce1a3580239f5 (diff) |
Add notifyInterval for MediaPlayer QML API
Expose notifyInterval as a property from QMediaPlayer.
Task-number: QTBUG-44961
Change-Id: Ia6c671eb68754e5c9a60032289bd821884824c78
Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
Diffstat (limited to 'src/imports/multimedia/qdeclarativeaudio.cpp')
-rw-r--r-- | src/imports/multimedia/qdeclarativeaudio.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 86f8f30ba..608337d54 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -119,6 +119,7 @@ QDeclarativeAudio::QDeclarativeAudio(QObject *parent) , m_status(QMediaPlayer::NoMedia) , m_error(QMediaPlayer::ServiceMissingError) , m_player(0) + , m_notifyInterval(1000) { } @@ -201,6 +202,34 @@ void QDeclarativeAudio::setAudioRole(QDeclarativeAudio::AudioRole audioRole) } /*! + \qmlproperty int QtMultimedia::Audio::notifyInterval + + The interval at which notifiable properties will update. + + The notifiable properties are \l position and \l bufferProgress. + + The interval is expressed in milliseconds, the default value is 1000. + + \since 5.9 +*/ +int QDeclarativeAudio::notifyInterval() const +{ + return m_complete ? m_player->notifyInterval() : m_notifyInterval; +} + +void QDeclarativeAudio::setNotifyInterval(int value) +{ + if (notifyInterval() == value) + return; + if (m_complete) { + m_player->setNotifyInterval(value); + return; + } + m_notifyInterval = value; + emit notifyIntervalChanged(); +} + +/*! \qmlmethod list<int> QtMultimedia::Audio::supportedAudioRoles() Returns a list of supported audio roles. @@ -813,6 +842,8 @@ void QDeclarativeAudio::classBegin() this, SIGNAL(hasVideoChanged())); connect(m_player, SIGNAL(audioRoleChanged(QAudio::Role)), this, SIGNAL(audioRoleChanged())); + connect(m_player, SIGNAL(notifyIntervalChanged(int)), + this, SIGNAL(notifyIntervalChanged())); m_error = m_player->availability() == QMultimedia::ServiceMissing ? QMediaPlayer::ServiceMissingError : QMediaPlayer::NoError; @@ -837,6 +868,8 @@ void QDeclarativeAudio::componentComplete() m_player->setPlaybackRate(m_playbackRate); if (m_audioRole != UnknownRole) m_player->setAudioRole(QAudio::Role(m_audioRole)); + if (m_notifyInterval != m_player->notifyInterval()) + m_player->setNotifyInterval(m_notifyInterval); if (!m_content.isNull() && (m_autoLoad || m_autoPlay)) { m_player->setMedia(m_content, 0); @@ -1157,6 +1190,18 @@ void QDeclarativeAudio::_q_mediaChanged(const QMediaContent &media) */ /*! + \qmlproperty int QtMultimedia::MediaPlayer::notifyInterval + + The interval at which notifiable properties will update. + + The notifiable properties are \l position and \l bufferProgress. + + The interval is expressed in milliseconds, the default value is 1000. + + \since 5.9 +*/ + +/*! \qmlmethod QtMultimedia::MediaPlayer::play() Starts playback of the media. |