How to use AudioHandler

Having problems with building or using the CefSharp .NET binding? Ask your CEF-related questions here. Please ask general usage questions on StackOverflow.

Moderator: amaitland

How to use AudioHandler

Postby ValentinNikin » Wed Jul 28, 2021 9:22 am

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
};
ValentinNikin
Techie
 
Posts: 34
Joined: Fri Jun 18, 2021 1:37 am

Re: How to use AudioHandler

Postby amaitland » Wed Jul 28, 2021 2:04 pm

What version are you using? Are you using WinForms or WPF or OffScreen?
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: How to use AudioHandler

Postby ValentinNikin » Wed Jul 28, 2021 3:12 pm

Hello, amaitland!
I use offscreen version.
Nuget packet (CefSharp.OffScreen) version is 91.1.211
ValentinNikin
Techie
 
Posts: 34
Joined: Fri Jun 18, 2021 1:37 am

Re: How to use AudioHandler

Postby amaitland » Wed Jul 28, 2021 3:42 pm

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
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: How to use AudioHandler

Postby ValentinNikin » Wed Jul 28, 2021 11:48 pm

It's work for me. Thank you
ValentinNikin
Techie
 
Posts: 34
Joined: Fri Jun 18, 2021 1:37 am


Return to CefSharp Forum

Who is online

Users browsing this forum: No registered users and 11 guests