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

JxBrowser supports web camera and microphone. By default, first webcam and microphone in the list of available video/audio capture devices are used as default. To get information about available media stream devices such as webcam or microphone, use the MediaStreamDeviceManager API.(JxBrowser支持网络摄像头和麦克风。默认情况下,可用视频/音频捕获设备列表中的第一个网络摄像头和麦克风用作默认设置。要获取有关可用媒体流设备(例如网络摄像头或麦克风)的信息,请使用MediaStreamDeviceManager API。)

Audio & Video Capture Devices(音频和视频捕获设备)

The following sample demonstrates how to get list of available audio and video capture devices:(下面的示例演示如何获取可用的音频和视频捕获设备的列表:)

final MediaStreamDeviceManager deviceManager = browser.getMediaStreamDeviceManager();
// Get list of all available audio capture devices (microphones).
List<MediaStreamDevice> audioCaptureDevices =
// Get list of all available video capture devices (webcams).
List<MediaStreamDevice> videoCaptureDevices =

Default Audio & Video Capture Devices(默认的音频和视频捕获设备)

By default, first webcam and microphone in the list of available video/audio capture devices are used as default. To change this default behavior register your own MediaStreamDeviceProvider implementation that configures default device. In your own implementation you let end user to select which devices should be used by default if there are more than one device is available.(默认情况下,可用视频/音频捕获设备列表中的第一个网络摄像头和麦克风用作默认设置。要更改此默认行为,请注册您自己的MediaStreamDeviceProvider实现,该实现配置默认设备。在您自己的实现中,如果有多个可用设备,则让最终用户选择默认情况下应使用哪些设备。)

// Register own provider to provide Chromium with default device.
deviceManager.setMediaStreamDeviceProvider(new MediaStreamDeviceProvider() {
    public void onRequestDefaultDevice(MediaStreamDeviceRequest request) {
        // Set first available device as default.
        List<MediaStreamDevice> availableDevices = request.getMediaStreamDevices();
        if (!availableDevices.isEmpty()) {
            MediaStreamDevice defaultDevice = availableDevices.get(0);