0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CefSharpでFlashを再生する方法

Last updated at Posted at 2020-05-28

はじめに

CefShrapでFlashが使えるようにする方法がけっこう複雑だったので、まとめておきます。

pepflashplayer.dllのダウンロード

CefSharpではFlashがサポートされていないので、FlashのDLLファイルを用意する必要があります。
こちらからバージョン28.0.0.137のものをダウンロードしてください。
最新のDLLだと動かないので注意してください。

ダウンロードしたらファイルを解凍し、pepflashplayer.dllを
プロジェクトフォルダ\bin\Debug
にコピーしておきます。

Flashの設定

CefSharpではFlashがデフォルトで無効化されているので、パラメータで設定します。

CefSettings settings = new CefSettings();
// レンダリングを最適化
settings.SetOffScreenRenderingBestPerformanceArgs();
// Flashを有効化
settings.CefCommandLineArgs.Add("enable-npapi", "1");
settings.CefCommandLineArgs.Add("ppapi-flash-path", "pepflashplayer.dll");
settings.CefCommandLineArgs.Add("ppapi-flash-version", "28.0.0.137");
settings.CefCommandLineArgs.Add("debug-plugin-loading", "1");
settings.CefCommandLineArgs.Add("allow-outdated-plugins", "1");
settings.CefCommandLineArgs.Add("always-authorize-plugins", "1");
settings.CefCommandLineArgs.Add("disable-web-security", "1");
settings.CefCommandLineArgs.Remove("enable-system-flash");
settings.CefCommandLineArgs.Add("enable-system-flash", "1");
settings.CefCommandLineArgs.Add("plugin-policy", "allow");
settings.CefCommandLineArgs.Add("disable-plugins-discovery", "1");
Cef.Initialize(settings);

// 自動再生を許可
var contx = Cef.GetGlobalRequestContext();
Cef.UIThreadTaskFactory.StartNew(delegate
{
    contx.SetPreference("profile.default_content_setting_values.plugins", 1, out string err);
});
cefBrowser = new ChromiumWebBrowser("https://www.google.co.jp/");

これで再生できるようになるはずです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?