Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Mute audio on instance based ?
-
- Posts: 460
- Joined: Thu Aug 10, 2017 12:40 pm
Mute audio on instance based ?
I know i can mute audio using this method :
GlobalCEFApp.MuteAudio := true
But this will mute audio for all instances of ChromiunWindow i create on my app.
Is there a way to mute just a specific instance ?
GlobalCEFApp.MuteAudio := true
But this will mute audio for all instances of ChromiunWindow i create on my app.
Is there a way to mute just a specific instance ?
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Mute audio on instance based ?
Try setting TChromiumCore.AudioMuted := True;
That property can only be read in the "UI" CEF thread. That's why the MiniBrowser demo uses the context menu to mute the audio of that browser :
https://github.com/salvadordf/CEF4Delphi/blob/15f51eccc759d893462b9068d97cc5b70c2d88f8/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L589
That property can only be read in the "UI" CEF thread. That's why the MiniBrowser demo uses the context menu to mute the audio of that browser :
https://github.com/salvadordf/CEF4Delphi/blob/15f51eccc759d893462b9068d97cc5b70c2d88f8/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L589
-
- Posts: 460
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Mute audio on instance based ?
Thank you !
-
- Posts: 460
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Mute audio on instance based ?
For youtube this method does not work. I used this method after creating the component, but even so the video sound is playing normally. Maybe you need to call this method after the page loads ? It it's the case, i could do the same thing using pure JS, my goal is to silence sound for any page loaded, but only in a specific instance of TChromiumWindow.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Mute audio on instance based ?
I just tested a YouTube video with MiniBrowser and the context menu to mute the audio works correctly.
This means that both the setter and the getter functions for the TChromiumCore.MuteAudio property need to be called in the CEF UI thread.
I'll modify the setter to make sure it's executed in the correct thread.
This means that both the setter and the getter functions for the TChromiumCore.MuteAudio property need to be called in the CEF UI thread.
I'll modify the setter to make sure it's executed in the correct thread.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Mute audio on instance based ?
Download CEF4Delphi again.
There's a new TChromiumCore.ToggleAudioMuted function used to enable and disable the audio in that browser. You can call this function from any thread.
Now the TChromiumCore.AudioMuted setter can be called from any thread but if you want to read the value of that property you'll need to do that from the CEF UI thread.
There's a new TChromiumCore.ToggleAudioMuted function used to enable and disable the audio in that browser. You can call this function from any thread.
Now the TChromiumCore.AudioMuted setter can be called from any thread but if you want to read the value of that property you'll need to do that from the CEF UI thread.
-
- Posts: 460
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Mute audio on instance based ?
Ok, will give it a try tonight, thank you !
-
- Posts: 460
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Mute audio on instance based ?
Now it's working, thanks !