Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.(注意:本文中的建议仅适用于JxBrowser6,JxBrowser7相应文章请点击这里。)


JxBrowser supports Adobe Flash plugin and can display Flash content on Windows and macOS platforms. In order to display Flash contents you need to download and install Flash Player. Flash content is displayed in windowless mode, so make sure that Flash content you display on the web page really supports this mode.(JxBrowser支持Adobe Flash插件,并且可以在Windows和macOS平台上显示Flash内容。为了显示Flash内容,您需要下载并安装Flash Player。 Flash内容以无窗口模式显示,因此请确保您在网页上显示的Flash内容确实支持此模式。)


NPAPI & PPAPI Plugins(NPAPI和PPAPI插件)

Since April 2015 Google Chrome stopped supporting NPAPI plugins. JxBrowser 6.4 and higher doesn't support NPAPI plugins as well. We recommend that you download and install Flash PPAPI plugin.(自2015年4月起,Chrome浏览器停止支持NPAPI插件。 JxBrowser 6.4和更高版本也不支持NPAPI插件。我们建议您下载并安装Flash PPAPI插件。)


Windows & Mac(Windows和Mac)

To download Flash PPAPI plugin go to https://get.adobe.com/flashplayer/otherversions, select your operating system and PPAPI plugin version in the second dropdown menu as shown blow:
(要下载Flash PPAPI插件,请访问https://get.adobe.com/flashplayer/otherversions,在第二个下拉菜单中选择操作系统和PPAPI插件版本,图略)

JxBrowser will automatically find installed Flash PPAPI plugin and use it to display Flash content.(JxBrowser将自动找到已安装的Flash PPAPI插件并将其用于显示Flash内容。)


Console Window Issue(控制台窗口问题)

On Windows you may notice that the PPAPI Flash player plugin briefly displays and hides a console window during startup. This console window displays the "NOT SANDBOXED" text and disappears immediately. The reason of this behavior is in disabled Chromium sandbox. By default, the Chromium sandbox is disabled. To get rid of this flashing console window you must enable Chromium sandbox.(在Windows上,您可能会注意到PPAPI Flash Player插件在启动期间会短暂显示和隐藏控制台窗口。该控制台窗口显示“ NO SANDBOXED”文本,并立即消失。此行为的原因是在禁用的Chromium沙箱中。默认情况下,Chromium沙箱处于禁用状态。要摆脱此闪烁的控制台窗口,必须启用Chromium沙箱。)




Linux(的Linux)

Installation process of PPAPI Flash can be different depending on Linux distribution. The following instruction describes how to install PPAPI Flash on Ubuntu 12.04+.
(PPAPI Flash的安装过程可能会有所不同,具体取决于Linux发行版。以下说明介绍了如何在Ubuntu 12.04+上安装PPAPI Flash。)


1. Add PPA repository and install pepflashplugin-installer package. (1.添加PPA存储库并安装pepflashplugin-installer软件包。)

sudo add-apt-repository ppa:skunk/pepper-flash
sudo apt-get update
sudo apt-get install pepflashplugin-installer


2. Specify path to the installed PPAPI Flash if necessary. JxBrowser searches PPAPI Flash in the default locations which are different on various Linux distributions. Here is the list of the locations where JxBrowser expects to find PPAPI Flash: (2.如有必要,请指定已安装PPAPI Flash的路径。 JxBrowser在默认位置搜索PPAPI Flash,默认位置在各种Linux发行版中都不同。这是JxBrowser期望找到PPAPI Flash的位置的列表:)

/usr/lib/pepflashplugin-installer/
/usr/lib/pepperflashplugin-nonfree/
/usr/lib/chromium/PepperFlash/
/usr/lib64/chromium/PepperFlash/


In case you have installed PPAPI Flash at a different location you must specify path to the Flash library using Chromium switchers as shown in the following sample: (如果您将PPAPI Flash安装在其他位置,则必须使用Chromium切换器指定Flash库的路径,如以下示例所示:)

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserPreferences;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;

import javax.swing.*;
import java.awt.*;

/**
 * This sample loads a web page with simple Flash content.
 */
public class FlashSample {
    public static void main(String[] args) {
        BrowserPreferences.setChromiumSwitches(
                "--ppapi-flash-path=/usr/lib/flash/libpepflashplayer.so", 
                "--ppapi-flash-version=20.0.0.270");
        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);

        JFrame frame = new JFrame("Flash Sample");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(800, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        browser.loadURL("http://www.webthrower.com/portfolio/narnia.htm");
    }
}