how to enable audio/sound of web media in cefsharp offscreen(c#)?

3k Views Asked by At

How do I enable audio/sound of web media in cefsharp offscreen? When using cefsharp winform, it works fine. audis is running.

However, I must use it offscreen, so I have changed from winform to offscreen. Thereafter, a failure audio running. Media audio is played using webRTC.

This is the CefSettings c# code.

CefSettings settings = new CefSettings();
CefSharpSettings.LegacyJavascriptBindingEnabled = true; // Enable Register JS Object, -- RegisterAsyncJsObject, RegisterJsObject allow

settings.CachePath = "cache";
settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC

//NOTE: The following function will set all three params
settings.CefCommandLineArgs.Add("disable-gpu", "1");
settings.CefCommandLineArgs.Add("disable-gpu-compositing", "1");

//NOTE: The Custom Scheme set up to embedded resources
settings.RegisterScheme(new CefCustomScheme()
{
   SchemeName = ResourceSchemeHandlerFactory.SchemeName,
   SchemeHandlerFactory = new ResourceSchemeHandlerFactory()
});

Cef.Initialize(settings);

This is browserSettings code.

BrowserSettings browserSettings = new BrowserSettings();
browserSettings.FileAccessFromFileUrls = CefState.Enabled;
browserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
browserSettings.WebSecurity = CefState.Disabled;

nxBrowser = new ChromiumWebBrowser("resource://web/nxwebRTCAPI.html", browserSettings);
nxBrowser.RegisterJsObject("callBackObj", this);

and this is the html source.

<body>
    <script src="js/nxWebApi.js"></script>
    <script src="js/nxCallBack.js"></script>

    <audio id="audio_remote" autoplay="autoplay"> </audio>
</body>
</html>

Please check my problems in the code.

0

There are 0 best solutions below