2018-08-12 15:09:27 +08:00
using CefSharp.Wpf ;
using System ;
2017-03-22 13:04:33 +08:00
using System.IO ;
2016-06-16 06:14:16 +08:00
using System.Windows ;
2013-11-12 19:14:11 +08:00
namespace CefSharp.MinimalExample.Wpf
{
public partial class App : Application
{
public App ( )
{
2021-02-08 14:53:54 +08:00
#if ANYCPU
//Only required for PlatformTarget of AnyCPU
2021-06-22 10:12:03 +08:00
CefRuntime . SubscribeAnyCpuAssemblyResolver ( ) ;
2021-02-08 14:53:54 +08:00
#endif
2017-03-22 13:04:33 +08:00
var settings = new CefSettings ( )
{
//By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
CachePath = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , "CefSharp\\Cache" )
} ;
2019-12-14 09:51:27 +08:00
2018-07-13 08:48:52 +08:00
//Example of setting a command line argument
//Enables WebRTC
2020-09-09 15:51:12 +08:00
// - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access
// - CEF Doesn't currently support displaying a UI for media access permissions
//
//NOTE: WebRTC Device Id's aren't persisted as they are in Chrome see https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart
2020-05-23 10:11:28 +08:00
settings . CefCommandLineArgs . Add ( "enable-media-stream" ) ;
2020-09-09 15:51:12 +08:00
//https://peter.sh/experiments/chromium-command-line-switches/#use-fake-ui-for-media-stream
settings . CefCommandLineArgs . Add ( "use-fake-ui-for-media-stream" ) ;
//For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180)
settings . CefCommandLineArgs . Add ( "enable-usermedia-screen-capturing" ) ;
2018-06-25 17:18:03 +08:00
2021-03-05 09:15:53 +08:00
//Example of checking if a call to Cef.Initialize has already been made, we require this for
//our .Net 5.0 Single File Publish example, you don't typically need to perform this check
//if you call Cef.Initialze within your WPF App constructor.
if ( ! Cef . IsInitialized )
{
//Perform dependency check to make sure all relevant resources are in our output directory.
2021-04-07 13:52:14 +08:00
Cef . Initialize ( settings , performDependencyCheck : true , browserProcessHandler : null ) ;
2021-03-05 09:15:53 +08:00
}
2013-11-12 19:14:11 +08:00
}
}
}