summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@theqtcompany.com>2015-12-14 14:54:39 +0100
committerAlexandru Croitor <alexandru.croitor@theqtcompany.com>2015-12-15 17:03:10 +0000
commit26aa7e314e58ea7be375fc767f6806127e50338d (patch)
treef1575597351effd890379420fca63f04100d8e87 /src/webengine
parent6414f93b39c57b2718a622430f7e0329b3512c8b (diff)
Add support for checking if audio is played in a page.
Add support for checking if audio is played in a page, as well as the ability to (un)mute the audio. Modify demobrowser example to show (muted) in the tab title, if the tab is muted, or (audible) if there is audio playing in the tab. Fix HTML5 audio/video (un)mute to also work. Change-Id: I7213645e67be2f9da1c5f96cdf6c7eef5341ae4b Task-number: QTBUG-48788 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp33
-rw-r--r--src/webengine/api/qquickwebengineview_p.h6
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webengine/doc/src/webengineview.qdoc34
4 files changed, 74 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index b9fa3d605..7b0ed0a33 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -392,6 +392,12 @@ void QQuickWebEngineViewPrivate::didUpdateTargetURL(const QUrl &hoveredUrl)
Q_EMIT q->linkHovered(hoveredUrl);
}
+void QQuickWebEngineViewPrivate::wasRecentlyAudibleChanged(bool wasRecentlyAudible)
+{
+ Q_Q(QQuickWebEngineView);
+ Q_EMIT q->wasRecentlyAudibleChanged(wasRecentlyAudible);
+}
+
QRectF QQuickWebEngineViewPrivate::viewportRect() const
{
Q_Q(const QQuickWebEngineView);
@@ -1084,6 +1090,33 @@ void QQuickWebEngineView::setBackgroundColor(const QColor &color)
emit backgroundColorChanged();
}
+/*!
+ \property QQuickWebEngineView::audioMuted
+ \brief the state of whether the current page audio is muted.
+ \since 5.7
+
+ The default value is false.
+*/
+bool QQuickWebEngineView::isAudioMuted() const {
+ const Q_D(QQuickWebEngineView);
+ return d->adapter->isAudioMuted();
+
+}
+void QQuickWebEngineView::setAudioMuted(bool muted) {
+ Q_D(QQuickWebEngineView);
+ bool _isAudioMuted = isAudioMuted();
+ d->adapter->setAudioMuted(muted);
+ if (_isAudioMuted != muted) {
+ Q_EMIT audioMutedChanged(muted);
+ }
+}
+
+bool QQuickWebEngineView::wasRecentlyAudible()
+{
+ Q_D(QQuickWebEngineView);
+ return d->adapter->wasRecentlyAudible();
+}
+
bool QQuickWebEngineView::isFullScreen() const
{
Q_D(const QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index a2f937968..9f7a45156 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -110,6 +110,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged REVISION 2)
Q_PROPERTY(QSizeF contentsSize READ contentsSize NOTIFY contentsSizeChanged FINAL REVISION 3)
Q_PROPERTY(QPointF scrollPosition READ scrollPosition NOTIFY scrollPositionChanged FINAL REVISION 3)
+ Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted NOTIFY audioMutedChanged REVISION 3)
#ifdef ENABLE_QML_TESTSUPPORT_API
Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL)
@@ -295,6 +296,9 @@ public Q_SLOTS:
Q_REVISION(1) void grantFeaturePermission(const QUrl &securityOrigin, Feature, bool granted);
Q_REVISION(2) void setActiveFocusOnPress(bool arg);
Q_REVISION(2) void triggerWebAction(WebAction action);
+ Q_REVISION(3) bool isAudioMuted() const;
+ Q_REVISION(3) void setAudioMuted(bool muted);
+ Q_REVISION(3) bool wasRecentlyAudible();
Q_SIGNALS:
void titleChanged();
@@ -319,6 +323,8 @@ Q_SIGNALS:
Q_REVISION(2) void windowCloseRequested();
Q_REVISION(3) void contentsSizeChanged(const QSizeF& size);
Q_REVISION(3) void scrollPositionChanged(const QPointF& position);
+ Q_REVISION(3) void audioMutedChanged(bool muted);
+ Q_REVISION(3) void wasRecentlyAudibleChanged(bool wasRecentlyAudible);
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 7fca79b7a..69ba60ccd 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -132,6 +132,7 @@ public:
virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE;
virtual void didUpdateTargetURL(const QUrl&) Q_DECL_OVERRIDE;
virtual void selectionChanged() Q_DECL_OVERRIDE { }
+ virtual void wasRecentlyAudibleChanged(bool wasRecentlyAudible) Q_DECL_OVERRIDE;
virtual QRectF viewportRect() const Q_DECL_OVERRIDE;
virtual qreal dpiScale() const Q_DECL_OVERRIDE;
virtual QColor backgroundColor() const Q_DECL_OVERRIDE;
diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc
index e687d54d9..49717ae50 100644
--- a/src/webengine/doc/src/webengineview.qdoc
+++ b/src/webengine/doc/src/webengineview.qdoc
@@ -740,3 +740,37 @@
\sa toggleOn
*/
+
+/*!
+ \qmlproperty bool WebEngineView::audioMuted
+ \brief The state of whether the current page audio is muted.
+ \since QtWebEngine 1.3
+*/
+
+/*!
+ \qmlsignal void WebEngineView::audioMutedChanged(bool muted)
+ \since QtWebEngine 1.3
+
+ This signal is emitted when the page's audio is (un)muted using setAudioMuted method.
+ \note Not to be confused with a specific HTML5 audio / video element being muted.
+*/
+
+/*!
+ \qmlmethod bool WebEngineView::wasRecentlyAudible()
+ \since QtWebEngine 1.3
+ \sa wasRecentlyAudibleChanged()
+
+ Returns the current page's audible state (audio was recently played, or not).
+*/
+
+/*!
+ \qmlsignal void WebEngineView::wasRecentlyAudibleChanged(bool wasRecentlyAudible)
+ \since QtWebEngine 1.3
+
+ This signal is emitted when the page's audible state is changed, due to audio
+ being played or stopped.
+
+ \note The signal is also emitted when calling the setAudioMuted method.
+ Also if the audio is paused, this signal is emitted with an approximate \b{2 second
+ delay}, from the moment the audio is paused.
+*/