summaryrefslogtreecommitdiff
path: root/src/imports/multimedia
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@theqtcompany.com>2016-04-15 18:35:33 +0300
committerYoann Lopes <yoann.lopes@qt.io>2016-09-07 12:48:40 +0000
commit62f1899a23b456f03cfccfaefcdf670d3cbb0f35 (patch)
tree236543eb24917fe4e153567a20b46dbd6a8ef612 /src/imports/multimedia
parent2d1c728c4c4522d0e405da514b6ce1a3580239f5 (diff)
downloadqtmultimedia-62f1899a23b456f03cfccfaefcdf670d3cbb0f35.tar.gz
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')
-rw-r--r--src/imports/multimedia/Video.qml15
-rw-r--r--src/imports/multimedia/multimedia.cpp2
-rw-r--r--src/imports/multimedia/qdeclarativeaudio.cpp45
-rw-r--r--src/imports/multimedia/qdeclarativeaudio_p.h5
4 files changed, 66 insertions, 1 deletions
diff --git a/src/imports/multimedia/Video.qml b/src/imports/multimedia/Video.qml
index 2188d17b9..70bd2ccf4 100644
--- a/src/imports/multimedia/Video.qml
+++ b/src/imports/multimedia/Video.qml
@@ -38,7 +38,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtMultimedia 5.6
+import QtMultimedia 5.9
/*!
\qmltype Video
@@ -374,6 +374,19 @@ Item {
property alias autoPlay: player.autoPlay
/*!
+ \qmlproperty int Video::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
+ */
+ property alias notifyInterval: player.notifyInterval
+
+ /*!
\qmlsignal Video::paused()
This signal is emitted when playback is paused.
diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp
index d249747b7..ced83a5b2 100644
--- a/src/imports/multimedia/multimedia.cpp
+++ b/src/imports/multimedia/multimedia.cpp
@@ -141,6 +141,8 @@ public:
trUtf8("CameraImageProcessing is provided by Camera"));
// 5.9 types
+ qmlRegisterType<QDeclarativeAudio, 2>(uri, 5, 9, "Audio");
+ qmlRegisterType<QDeclarativeAudio, 2>(uri, 5, 9, "MediaPlayer");
qmlRegisterUncreatableType<QDeclarativeCameraCapture, 1>(uri, 5, 9, "CameraCapture",
trUtf8("CameraCapture is provided by Camera"));
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.
diff --git a/src/imports/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h
index 48c8704e9..ad30fa729 100644
--- a/src/imports/multimedia/qdeclarativeaudio_p.h
+++ b/src/imports/multimedia/qdeclarativeaudio_p.h
@@ -95,6 +95,7 @@ class QDeclarativeAudio : public QObject, public QQmlParserStatus
Q_PROPERTY(QObject *mediaObject READ mediaObject NOTIFY mediaObjectChanged SCRIPTABLE false DESIGNABLE false)
Q_PROPERTY(Availability availability READ availability NOTIFY availabilityChanged)
Q_PROPERTY(AudioRole audioRole READ audioRole WRITE setAudioRole NOTIFY audioRoleChanged REVISION 1)
+ Q_PROPERTY(int notifyInterval READ notifyInterval WRITE setNotifyInterval NOTIFY notifyIntervalChanged REVISION 2)
Q_ENUMS(Status)
Q_ENUMS(Error)
Q_ENUMS(Loop)
@@ -214,6 +215,8 @@ public:
bool autoPlay() const;
void setAutoPlay(bool autoplay);
+ int notifyInterval() const;
+ void setNotifyInterval(int);
public Q_SLOTS:
void play();
@@ -260,6 +263,7 @@ Q_SIGNALS:
void error(QDeclarativeAudio::Error error, const QString &errorString);
void mediaObjectChanged();
+ Q_REVISION(2) void notifyIntervalChanged();
private Q_SLOTS:
void _q_error(QMediaPlayer::Error);
@@ -294,6 +298,7 @@ private:
QScopedPointer<QDeclarativeMediaMetaData> m_metaData;
QMediaPlayer *m_player;
+ int m_notifyInterval;
friend class QDeclarativeMediaBaseAnimation;
};