0

I have a Web Browser in my WPF application which plays a Flash, but the Flash has audio and I don't want the users to hear it. I'm assuming that there has to be some way to mute either the Web Browser, the Window or the entire Application. I've tried stuff like the following, but nothing has worked. Could I get some assistance, please?

private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int WM_APPCOMMAND = 0x319;

[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam,
IntPtr lParam);

public EditTags() {
    IntPtr windowHandle = new WindowInteropHelper(this).Handle;
    SendMessageW(windowHandle, WM_APPCOMMAND, windowHandle, (IntPtr)
    APPCOMMAND_VOLUME_MUTE);
}

EDIT: A solution has been found by Jimi.

Link for those who want it: Webbrowser disable all audio output - from online radio to youtube.

  • is muting the entire OS an option? https://stackoverflow.com/questions/2986007/mute-unmute-change-master-volume-in-windows-7-x64-with-c-sharp – Daniel Feb 21 '19 at 23:46
  • Let me know if this is a duplicate: https://stackoverflow.com/questions/28217411/c-sharp-disable-webbrowser-sound-application-sound – Jeremy Thompson Feb 21 '19 at 23:57
  • [Core Audio APIs](https://learn.microsoft.com/en-us/windows/desktop/CoreAudio/core-audio-apis-in-windows-vista). C# + VB.Net implementations here: [How to check if the system audio is muted?](https://stackoverflow.com/q/52001368/7444103). – Jimi Feb 22 '19 at 00:11
  • @Daniel Muting the entire OS is not an option, no. It should be limited to the application. – MadCreativity Feb 22 '19 at 16:47
  • It doesn't look like any of the supplied solutions work. I'm assuming that it's due to them all being Windows Forms focused, but I don't know why that would be the case. – MadCreativity Feb 22 '19 at 17:28
  • The Core Audio APIs have nothing to do with WinForms or any other UI framework. – Jimi Feb 22 '19 at 18:27
  • @Jimi You're correct that the Core Audio API solution does not have to do with Windows Forms, but it doesn't work in this case because it mutes the audio device itself. I just want the WebBrowser or Application or Window to *not* output audio. – MadCreativity Feb 22 '19 at 19:29
  • 1
    Core Audio can be complicated. A simplified version, using `winmm`: [Webbrowser disable all audio output - from online radio to youtube](https://stackoverflow.com/a/18348015/7444103). – Jimi Feb 22 '19 at 20:44
  • 1
    Thank you so much, @Jimi. It worked exactly as I wanted. I really appreciate the help. – MadCreativity Feb 23 '19 at 18:27
  • I'm glad it was useful. If you have a specific implementation, maybe post it as an answer. It might be useful to someone else. – Jimi Feb 23 '19 at 18:31

0 Answers0