New version is available You are viewing the documentation for JxBrowser 6 which is not supported since December 2019. Go to the current documentation.
List icon 目录

This guide gives an overview of the supported video and audio formats, describes how to control audio, get information about available web cameras and microphones, etc.

Codecs

Google Chrome and Chromium differ in several ways, including the sets of audio and video codecs they support.

The table below displays which codecs are supported by the codebase of corresponding browsers.

  Chromium Google Chrome
AAC   yes
H.264   yes
MP3 yes yes
MP4   yes
Opus yes yes
Theora yes yes
Vorbis yes yes
VP8 yes yes
VP9 yes yes
WAV yes yes


As you may see, Google Chrome supports H.264, AAC, and MP4 codecs while Chromium does not. The reason is that these codecs are proprietary and cannot be used in an open-source or a commercial project without obtaining licenses from corresponding patent holders.

Different codecs have different patent holders. For example, in order to use H.264, companies must acquire the license from MPEG-LA company. You can read more about their license terms on the MPEG-LA’s website.

Proprietary Codecs

Patent holders don’t licence codecs to the software that represent only a part of the final product deployed to the end users (e.g. libraries, such as JxBrowser). In order to support H.264, MP4 and other proprietary codecs in your products, you need to acquire an appropriate licence.

If you need to play MP4 or H.264 formats on the web pages loaded in JxBrowser, you need to perform the following actions:

  1. Contact the patent holder (e.g. MPEG-LA) and obtain licence to use the proprietary codecs you need.
  2. Contact our support team and request a custom build of JxBrowser with enabled proprietary codecs. If you are not yet a customer of JxBrowser, please write to sales@teamdev.com.

With the licence and custom JxBrowser build, you will be able to load web pages with the MP4 or H.264 formats and play audio and video files, just like in Google Chrome.

Video

JxBrowser fully supports HTML5 <video> element and can play video in the supported formats.

If the library cannot play a video, or a video format is unsupported, JxBrowser suggests to download the video file.

HTML5 Video

Audio

You can mute or unmute audio on the loaded web page if required:

browser.setAudioMuted(true);

To check whether audio is muted use the following code:

boolean audioMuted = browser.isAudioMuted();

Widevine

JxBrowser does not support Widevine at the moment. Web services that use Widevine to distribute content, such as Netflix, Amazon Prime, etc., do not work in JxBrowser/Chromium.

Camera & Microphone

JxBrowser supports web camera and microphone.

You can get information about all available media stream devices using the following code:

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

Selecting Media Device

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.

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