MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Get and set audio volume

Open
#41 27 comments 3 reactions 1 assignee View on GitHub

@Lakshmisha-KS is already working on this.

Since Mar 3, 2025.

feature request priority-low tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Every so often, we receive yet another request for a feature that controls the audio volume of the web component. So far, we have been unable to fulfill this request. Can an AudioVolume property (equivalent to the following C# snippet) be added to WebView2?

class WebView2
{
    ...
    public double AudioVolume { get; set; }
    // Optional:   public bool IsAudioVolumeMuted { get; set; }
    ...
}

If you want, you could include the IsAudioVolumeMuted property to support a mute/unmute setting, but this isn't strictly essential, because apps can build their own mute/unmute setting atop the AudioVolume property. Note mute is different to setting the AudioVolume property to zero.

Valid values for the AudioVolume property would probably range from 0.0 (meaning 0%) to 1.0 (meaning 100%), but you might decide to also allow values greater than 100% because some volume controls do actually support "overdrive" or "boost" volumes, especially in cases where the source audio material may contain quiet sounds. Your choice.

I would find it helpful if the documentation states what scale the volume operates on:

  1. Logarithmic, or
  2. Linear.

Some audio volume slider widgets operate on a logarithmic scale while others are linear. A way of fixing a poorly performing volume slider is to change it to a logarithmic scale. However if the AudioVolume property is already logarithmic but the documentation doesn't state it, then an audio volume slider widget may be accidentally implemented as double log, which again produces a poorly behaving slider, thus clear documentation is helpful.

The proposed AudioVolume property would control the volume of all audio output produced by WebView2, including the following. Here is a list of tests to be performed after the volume feature is implemented:

  • Playback of video elements embedded in HTML webpages.
  • Playback of non-embedded video files (when WebView2 is directly navigated to a URI that directly returns a video file without HTML).
  • Audio elements such as playback of .WAV files.
  • Any audio produced via ECMAScript.
  • Fullscreen video elements.

I have not been able to workaround the lack of volume control by setting the system volume because:

  1. I couldn't work out how to correctly set the system volume. Windows (or the documentation) doesn't make it easy (or maybe it's easy but only if you know how).
  2. Even if I knew how to set the system volume, it's only partially helpful. It's not a full solution because we have alert/notifications sounds (outside of web) that should play at 100% volume while the web component should be 30% for example. Thus if the system volume is set to 30%, the alert sounds become so quiet that they're missed by people. Thus ideally WebView2's volume could be set independently.
  3. Even if the correct Win32 functions are known for setting the system volume, they're not necessarily allowed in the UWP sandbox.

AB#37633577

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.