From 555d883bd0d1cc4cd6bd60b515d5396cb76bac55 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 10 Jul 2018 17:14:28 +0100 Subject: [PATCH] :wrench: Add isCurrentlyAudible() to WebContents --- atom/browser/api/atom_api_web_contents.cc | 5 +++++ atom/browser/api/atom_api_web_contents.h | 1 + docs/api/web-contents.md | 4 ++++ docs/api/webview-tag.md | 4 ++++ lib/renderer/web-view/web-view.js | 1 + 5 files changed, 15 insertions(+) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 548ea394436b4..9e613f4bb692b 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1434,6 +1434,10 @@ bool WebContents::IsAudioMuted() { return web_contents()->IsAudioMuted(); } +bool WebContents::IsCurrentlyAudible() { + return web_contents()->IsCurrentlyAudible(); +} + void WebContents::Print(mate::Arguments* args) { PrintSettings settings = {false, false, base::string16()}; if (args->Length() >= 1 && !args->GetNext(&settings)) { @@ -2018,6 +2022,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("setIgnoreMenuShortcuts", &WebContents::SetIgnoreMenuShortcuts) .SetMethod("setAudioMuted", &WebContents::SetAudioMuted) .SetMethod("isAudioMuted", &WebContents::IsAudioMuted) + .SetMethod("isCurrentlyAudible", &WebContents::IsCurrentlyAudible) .SetMethod("undo", &WebContents::Undo) .SetMethod("redo", &WebContents::Redo) .SetMethod("cut", &WebContents::Cut) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 2155656ccbdcc..1e3c7a927adb9 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -143,6 +143,7 @@ class WebContents : public mate::TrackableObject, void SetIgnoreMenuShortcuts(bool ignore); void SetAudioMuted(bool muted); bool IsAudioMuted(); + bool IsCurrentlyAudible(); void Print(mate::Arguments* args); std::vector GetPrinterList(); void SetEmbedder(const WebContents* embedder); diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index efba30d5be16f..0740e7df6dcae 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -832,6 +832,10 @@ Mute the audio on the current web page. Returns `Boolean` - Whether this page has been muted. +#### `contents.isCurrentlyAudible()` + +Returns `Boolean` - Whether audio is currently playing. + #### `contents.setZoomFactor(factor)` * `factor` Number - Zoom factor. diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index 25edb6052f752..116e5a42fb3bd 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -450,6 +450,10 @@ Set guest page muted. Returns `Boolean` - Whether guest page has been muted. +#### `.isCurrentlyAudible()` + +Returns `Boolean` - Whether audio is currently playing. + ### `.undo()` Executes editing command `undo` in page. diff --git a/lib/renderer/web-view/web-view.js b/lib/renderer/web-view/web-view.js index 544652e44756f..d2ae6bf7efb0f 100644 --- a/lib/renderer/web-view/web-view.js +++ b/lib/renderer/web-view/web-view.js @@ -344,6 +344,7 @@ const registerWebViewElement = function () { 'inspectElement', 'setAudioMuted', 'isAudioMuted', + 'isCurrentlyAudible', 'undo', 'redo', 'cut',