Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.(注意:本文中的建议仅适用于JxBrowser6,JxBrowser7相应文章请点击这里。)
JxBrowser supports HTML5 video and audio. The following example demonstrates HTML5 video support:(JxBrowser支持HTML5视频和音频。以下示例演示了HTML5视频支持:)
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import javax.swing.*;
import java.awt.*;
public class BrowserSample {
public static void main(String[] args) {
Browser browser = new Browser();
BrowserView view = new BrowserView(browser);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(view, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
browser.loadURL("http://www.quirksmode.org/html5/tests/video.html");
}
}
Read more about supported audio/video codecs in the MP3/MP4/H.264 article.(在MP3 / MP4 / H.264文章中阅读有关受支持的音频/视频编解码器的更多信息。)