最近發現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);