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 Contents

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.

ChromiumGoogle Chrome
AACyes
H.264yes
MP3yesyes
MP4yes
Opusyesyes
Theorayesyes
Vorbisyesyes
VP8yesyes
VP9yesyes
WAVyesyes

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, to use H.264, companies must acquire the license from Via LA company. You can read more about their license terms on the 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);
        }
    }
});