Modify the volume of audio in CEF with media codecs enabled

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Modify the volume of audio in CEF with media codecs enabled

Postby callum » Wed Apr 22, 2020 12:31 am

The system we have in our Windows / CEF 72 application to set volume levels when media like YouTube is played no longer works after I updated to a build of CEF 81 with media codecs enabled.

I see CefBrowserHost::SetAudioMuted() and was hoping for CefBrowserHost::SetAudioVolume() but that doesn't exist.

I am curious why my audio volume control no longer works and would be grateful for pointers to how it should be done in CEF 81 + media.

Maybe CefAudioHandler() is the right way but that seems like overkill if all I want to do is change the volume and not interested in buffering the raw audio data.

Thanks in advance.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby magreenblatt » Wed Apr 22, 2020 10:35 am

callum wrote:I am curious why my audio volume control no longer works

How did you implement your volume control?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby callum » Wed Apr 22, 2020 11:10 am

Adding a --force-wave-audio command line parameter to CEF (v72.x and offscreen rendering) and Windows SDK waveOutSetVolume(..) calls in the application itself to change the audio level based on the users' proximity to the playing media source.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby magreenblatt » Wed Apr 22, 2020 11:20 am

The audio service moved to a separate process in M78. You can try adding the `--disable-features=AudioServiceOutOfProcess` command-line flag.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby callum » Wed Apr 22, 2020 1:10 pm

That seems to help a lot - in my test app at least. It'll take me a while to push it through the various layers of our app/build system but I'm hopeful.

Is there a preferred way to deal with the audio stream - maybe what you suggested is it? The BrowserClient::CefAudioHandler() code seems have been removed. at M77 ?

Thank you.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby magreenblatt » Wed Apr 22, 2020 2:12 pm

The CefAudioHandler implementation (redone in this PR) is for receiving the audio stream data, not for controlling volume. We’ve recommended the use of system APIs to control volume in the past. If that won’t work with the audio service enabled then some other method (calling Chromium APIs) can probably be found.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby callum » Wed Apr 22, 2020 6:08 pm

magreenblatt wrote:The CefAudioHandler implementation (redone in this PR) is for receiving the audio stream data, not for controlling volume. We’ve recommended the use of system APIs to control volume in the past. If that won’t work with the audio service enabled then some other method (calling Chromium APIs) can probably be found.


Understood re: CefAudioHandler and I will track that PR in case we can use it - grabbing the raw audio data and shoveling it into an audio output device that is under our control sounds a bit scary but I expect it can be done.

Your command line solution appeared to do the trick and restored the attenuation feature - thanks for you help.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby callum » Wed May 27, 2020 3:28 pm

magreenblatt wrote:The CefAudioHandler implementation (redone in this PR) is for receiving the audio stream data, not for controlling volume. We’ve recommended the use of system APIs to control volume in the past. If that won’t work with the audio service enabled then some other method (calling Chromium APIs) can probably be found.


Forcing the use of WAVE audio on windows and associated command line flags breaks most of the media sites we care about (Twitch, Mixer etc.) can you elaborate on "some other method (calling Chromium APIs) can probably be found" ?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby magreenblatt » Wed May 27, 2020 5:06 pm

We would need to look at how Chromium controls the volume internally (when adjusting the volume control on an audio/video tag, for example), and then see if we can expose that same control programmatically.

Note that you can also change the volume using JavaScript. Injecting JavaScript into a page that walks the DOM looking for audio/video elements might be a faster solution.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Modify the volume of audio in CEF with media codecs enab

Postby callum » Wed May 27, 2020 5:19 pm

Understood and fascinating idea about JavaScript. I'll give it a go.

The PR you had pointed out previously https://bitbucket.org/chromiumembedded/ ... e-api/diff - seems to be moving along too.

Thank you!
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 84 guests