@@ -162,6 +162,18 @@ Loads the given HTML file, relative to the root of the application.
162162- ` filePath ` - Path to the HTML file
163163- ` options ` - Optional ` Query ` , ` Search ` and ` Hash ` parts of the resulting URL
164164
165+ #### 🧊 ` void SetAudioMuted(bool muted) `
166+ Mutes or unmutes the audio on the current web page.
167+
168+ #### 🧊 ` Task<bool> IsAudioMutedAsync() `
169+ Whether this page has been muted.
170+
171+ #### 🧊 ` Task<bool> IsCurrentlyAudibleAsync() `
172+ Whether audio is currently playing.
173+
174+ #### 🧊 ` Task<string> GetUserAgentAsync() ` / ` void SetUserAgent(string userAgent) `
175+ Gets or overrides the user agent for this web page.
176+
165177#### 🧊 ` Task<bool> IsLoadingAsync() `
166178Whether the web page is still loading resources.
167179
@@ -192,6 +204,9 @@ Copies the image at the given position to the clipboard.
192204#### 🧊 ` void SelectAll() ` / ` void Unselect() ` / ` void CenterSelection() `
193205Selects all content, clears the selection, or scrolls to the current selection.
194206
207+ #### 🧊 ` void ScrollToTop() ` / ` void ScrollToBottom() `
208+ Scrolls to the top or the bottom of the current web page.
209+
195210#### 🧊 ` void AdjustSelection(AdjustSelectionOptions options) `
196211Adjusts the start and end points of the current text selection by the given amounts. Negative amounts move towards the beginning of the document.
197212
@@ -250,6 +265,15 @@ Emitted when the user changes the zoom level using the mouse wheel or the keyboa
250265#### ⚡ ` OnFoundInPage `
251266Emitted when a result is available for a ` FindInPageAsync ` request. The handler receives a ` FoundInPageResult ` .
252267
268+ #### ⚡ ` OnAudioStateChanged `
269+ Emitted when media becomes audible or inaudible. The handler receives ` true ` if one or more frames or child web contents are emitting audio.
270+
271+ #### ⚡ ` OnMediaStartedPlaying `
272+ Emitted when media starts playing.
273+
274+ #### ⚡ ` OnMediaPaused `
275+ Emitted when media is paused or done playing.
276+
253277## Usage Examples
254278
255279### Page Loading
@@ -446,6 +470,23 @@ webContents.OnFoundInPage += (result) =>
446470var requestId = await webContents .FindInPageAsync (" electron" , new FindInPageOptions { MatchCase = false });
447471```
448472
473+ ### Audio
474+
475+ ``` csharp
476+ webContents .SetAudioMuted (true );
477+
478+ var muted = await webContents .IsAudioMutedAsync ();
479+ var audible = await webContents .IsCurrentlyAudibleAsync ();
480+
481+ webContents .OnAudioStateChanged += (isAudible ) =>
482+ {
483+ Console .WriteLine (isAudible ? " Page started emitting audio" : " Page went silent" );
484+ };
485+
486+ webContents .OnMediaStartedPlaying += () => Console .WriteLine (" Media playing" );
487+ webContents .OnMediaPaused += () => Console .WriteLine (" Media paused" );
488+ ```
489+
449490## Related APIs
450491
451492- [ Electron.WindowManager] ( WindowManager.md ) - Windows containing web contents
0 commit comments