[原创]Cef3 2623.1397 开启ppapi flash插件

最近发现WKE播放Flash或者游戏时会有很多BUG,例如视频无法播放或者是Stage3D无法使用等问题。

经过研究应该是精简版本导致的,所以决定尝试使用CEF3移植入SOUI,但是DEMO中版本有点旧,所以想升级。

发现23XX版本开始 无法直接使用npapi的flash插件,默认是关闭的

这里以CEF的DEMO程序CEFCLIENT为例子:

有2种方式可以启动FLASH插件,但是我不推荐NPAPI方式,实际上非常不好,据说是效率低下以及不稳定。

所以这里默认为PPAPI的方式。

(这里说的是FLASH插件的NPAPI版本卡,不是说NPAPI卡,我措辞不严谨,和PPAPI和NPAPI本身技术无关,仅仅针对FLASH插件,不信的自己可以试试)

 

首先要做的:

在CEFCLIENT目录下新建目录 PepperFlash 把下载好的 pepflashplayer.dll 插件丢入该目录即可。

然后跟着以下方法做。

方法1:

直接给编译好的CEFCLIENT创建一个快捷方式 快捷方式后加入参数 --register-pepper-plugins="PepperFlash/pepflashplayer.dll;application/x-shockwave-flash" 然后使用快捷方式启动即可发现FLASH正常播放。

如果希望开启NPAPI方式,再加入参数 --enable-npapi 即可。

 

方法2:

不像以上方法,需要快捷方式等,可以无参数启动。

打开源码 CEFCLIENT,并且打开文件 client_app_browser.cc 文件,找到函数 OnBeforeCommandLineProcessing。

 1 void ClientAppBrowser::OnBeforeCommandLineProcessing(
 2     const CefString& process_type,
 3     CefRefPtr<CefCommandLine> command_line) {
 4   // Pass additional command-line flags to the browser process.
 5   if (process_type.empty()) {
 6     // Pass additional command-line flags when off-screen rendering is enabled.
 7     if (command_line->HasSwitch(switches::kOffScreenRenderingEnabled)) {
 8       // If the PDF extension is enabled then cc Surfaces must be disabled for
 9       // PDFs to render correctly.
10       // See https://bitbucket.org/chromiumembedded/cef/issues/1689 for details.
11       if (!command_line->HasSwitch("disable-extensions") &&
12           !command_line->HasSwitch("disable-pdf-extension")) {
13         command_line->AppendSwitch("disable-surfaces");
14       }
15 
16       // Use software rendering and compositing (disable GPU) for increased FPS
17       // and decreased CPU usage. This will also disable WebGL so remove these
18       // switches if you need that capability.
19       // See https://bitbucket.org/chromiumembedded/cef/issues/1257 for details.
20       if (!command_line->HasSwitch(switches::kEnableGPU)) {
21         command_line->AppendSwitch("disable-gpu");
22         command_line->AppendSwitch("disable-gpu-compositing");
23       }
24 
25       // Synchronize the frame rate between all processes. This results in
26       // decreased CPU usage by avoiding the generation of extra frames that
27       // would otherwise be discarded. The frame rate can be set at browser
28       // creation time via CefBrowserSettings.windowless_frame_rate or changed
29       // dynamically using CefBrowserHost::SetWindowlessFrameRate. In cefclient
30       // it can be set via the command-line using `--off-screen-frame-rate=XX`.
31       // See https://bitbucket.org/chromiumembedded/cef/issues/1368 for details.
32       command_line->AppendSwitch("enable-begin-frame-scheduling");
33     }
34 
35     // 此参数解决多窗口问题
36     command_line->AppendSwitch("process-per-site");
37     command_line->AppendSwitch("enable-npapi");
38     command_line->AppendSwitchWithValue("register-pepper-plugins", "PepperFlash/pepflashplayer.dll;application/x-shockwave-flash");
39 
40     DelegateSet::iterator it = delegates_.begin();
41     for (; it != delegates_.end(); ++it)
42       (*it)->OnBeforeCommandLineProcessing(this, command_line);
43   }
44 }

修改代码如上,重新编译即可。

再打开YOUKU看看,是不是OK了。

还有发现右键菜单都是英文,这里可以在SETTINGS中设置参数locale为zh-CN即可。

1   std::string locale("zh-CN");
2   cef_string_utf8_to_utf16(locale.c_str(), locale.size(), &settings.locale);

 

posted @ 2016-04-15 21:20  koangel  阅读(9189)  评论(1编辑  收藏  举报