Page 1 of 1

How to use AudioHandler

PostPosted: Wed Jul 28, 2021 9:22 am
by ValentinNikin
I want to get sound from the opened resource.

Let's say that resource is video from youtube.

I inherited from AudioHandler and overrided all methods (GetAudioParameters/OnAudioStreamStarted/OnAudioStreamPacket/OnAudioStreamError/OnAudioStreamStopped).

Next, I created instance of my AudioHandlerCustom class and set this instance to ChromiumWebBrowser.

I expect overrided methods will called by Cef, but anyone methods weren't called.

Code: Select all
var audioHandler = new AudioHandlerCustom();

browser = new ChromiumWebBrowser(settings.GraphicsOutputUrl, null, new RequestContext(), false)
{
      Size = new System.Drawing.Size(settings.Width, settings.Height),
      RequestHandler = requestHandler,
      AudioHandler = audioHandler
};

Re: How to use AudioHandler

PostPosted: Wed Jul 28, 2021 2:04 pm
by amaitland
What version are you using? Are you using WinForms or WPF or OffScreen?

Re: How to use AudioHandler

PostPosted: Wed Jul 28, 2021 3:12 pm
by ValentinNikin
Hello, amaitland!
I use offscreen version.
Nuget packet (CefSharp.OffScreen) version is 91.1.211

Re: How to use AudioHandler

PostPosted: Wed Jul 28, 2021 3:42 pm
by amaitland
By default the OffScreen version has audio muted.

https://github.com/cefsharp/CefSharp/bl ... ngs.cs#L29

You can call EnableAudio before calling Cef.Initialize

Re: How to use AudioHandler

PostPosted: Wed Jul 28, 2021 11:48 pm
by ValentinNikin
It's work for me. Thank you