summaryrefslogtreecommitdiffstats
path: root/src/imports/multimedia/qdeclarativeaudio.cpp
diff options
context:
space:
mode:
authorJames McDonnell <jmcdonnell@blackberry.com>2017-03-28 17:23:25 -0400
committerJames McDonnell <jmcdonnell@blackberry.com>2017-10-23 14:10:43 +0000
commit82694e41b1d37e04ecc911f420ad4317220f8180 (patch)
tree831804b09c5fc36be0e103444c596149771d4a78 /src/imports/multimedia/qdeclarativeaudio.cpp
parent66c0334a3c4cb8deb63c67aa70da3f4ed94f89a4 (diff)
Propagate customAudioRole into the QML classes
Propagate customAudioRole into the Audio, MediaPlayer and Video classes. [ChangeLog][Audio/Video/MediaPlayer] Added customAudioRole string property to enable use of audio roles beyond those available via the audioRole enum property. Change-Id: If3c4ec20f014653d31d1fa0d1ad925084f446478 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/imports/multimedia/qdeclarativeaudio.cpp')
-rw-r--r--src/imports/multimedia/qdeclarativeaudio.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp
index 652296509..65606b3cf 100644
--- a/src/imports/multimedia/qdeclarativeaudio.cpp
+++ b/src/imports/multimedia/qdeclarativeaudio.cpp
@@ -179,8 +179,11 @@ QDeclarativeAudio::Availability QDeclarativeAudio::availability() const
\li AccessibilityRole - for accessibility, such as with a screen reader.
\li SonificationRole - sonification, such as with user interface sounds.
\li GameRole - game audio.
+ \li CustomRole - The role is specified by customAudioRole.
\endlist
+ customAudioRole is cleared when this property is set to anything other than CustomRole.
+
\since 5.6
*/
QDeclarativeAudio::AudioRole QDeclarativeAudio::audioRole() const
@@ -196,12 +199,49 @@ void QDeclarativeAudio::setAudioRole(QDeclarativeAudio::AudioRole audioRole)
if (m_complete) {
m_player->setAudioRole(QAudio::Role(audioRole));
} else {
+ if (!m_customAudioRole.isEmpty()) {
+ m_customAudioRole.clear();
+ emit customAudioRoleChanged();
+ }
m_audioRole = audioRole;
emit audioRoleChanged();
}
}
/*!
+ \qmlproperty string QtMultimedia::Audio::customAudioRole
+
+ This property holds the role of the audio stream when the backend supports audio
+ roles unknown to Qt. It can be set to specify the type of audio being played,
+ allowing the system to make appropriate decisions when it comes to volume,
+ routing or post-processing.
+
+ The audio role must be set before setting the source property.
+
+ audioRole is set to CustomRole when this property is set.
+
+ \since 5.11
+*/
+QString QDeclarativeAudio::customAudioRole() const
+{
+ return !m_complete ? m_customAudioRole : m_player->customAudioRole();
+}
+
+void QDeclarativeAudio::setCustomAudioRole(const QString &audioRole)
+{
+ if (this->customAudioRole() == audioRole)
+ return;
+
+ if (m_complete) {
+ m_player->setCustomAudioRole(audioRole);
+ } else {
+ setAudioRole(QDeclarativeAudio::CustomRole);
+ m_customAudioRole = audioRole;
+ emit customAudioRoleChanged();
+ }
+}
+
+/*!
\qmlproperty int QtMultimedia::Audio::notifyInterval
The interval at which notifiable properties will update.
@@ -850,6 +890,8 @@ void QDeclarativeAudio::classBegin()
this, SIGNAL(hasVideoChanged()));
connect(m_player, SIGNAL(audioRoleChanged(QAudio::Role)),
this, SIGNAL(audioRoleChanged()));
+ connect(m_player, SIGNAL(customAudioRoleChanged(const QString &)),
+ this, SIGNAL(customAudioRoleChanged()));
connect(m_player, SIGNAL(notifyIntervalChanged(int)),
this, SIGNAL(notifyIntervalChanged()));
@@ -876,6 +918,8 @@ void QDeclarativeAudio::componentComplete()
m_player->setPlaybackRate(m_playbackRate);
if (m_audioRole != UnknownRole)
m_player->setAudioRole(QAudio::Role(m_audioRole));
+ if (!m_customAudioRole.isEmpty())
+ m_player->setCustomAudioRole(m_customAudioRole);
if (m_notifyInterval != m_player->notifyInterval())
m_player->setNotifyInterval(m_notifyInterval);
@@ -1181,12 +1225,30 @@ void QDeclarativeAudio::_q_mediaChanged(const QMediaContent &media)
\li AccessibilityRole - for accessibility, such as with a screen reader.
\li SonificationRole - sonification, such as with user interface sounds.
\li GameRole - game audio.
+ \li CustomRole - The role is specified by customAudioRole.
\endlist
+ customAudioRole is cleared when this property is set to anything other than CustomRole.
+
\since 5.6
*/
/*!
+ \qmlproperty string QtMultimedia::MediaPlayer::customAudioRole
+
+ This property holds the role of the audio stream when the backend supports audio
+ roles unknown to Qt. It can be set to specify the type of audio being played,
+ allowing the system to make appropriate decisions when it comes to volume,
+ routing or post-processing.
+
+ The audio role must be set before setting the source property.
+
+ audioRole is set to CustomRole when this property is set.
+
+ \since 5.11
+*/
+
+/*!
\qmlmethod list<int> QtMultimedia::MediaPlayer::supportedAudioRoles()
Returns a list of supported audio roles.