Android: Source Selection

Video Cloud
Brightcove Player
Device SDK Developer
Develop with the Native SDKs

In this topic, you will learn how the Brightcove Native Player SDK for Android uses a default source selection process when playing a video.

When you retrieve videos from the Brightcove catalog, the SDK has to decide which source to play. This is implemented in the DefaultSourceSelectionController and ExoPlayerSourceSelectionController components.

Default selection process

The Brightcove Player SDK for Android uses a default source selection process. To simplify, we will focus on the SDK’s support for the Brightcove Playback API and Google’s ExoPlayer.

The default selection process is defined as follows:

  1. The BrightcoveExoPlayerVideoView looks for the first source that has a deliveryType of MPEG-DASH, and a profile that is neither urn:hbbtv nor urn:dvb. The SDK does not support playback with either of these DASH profiles, and so they will be filtered out of the sources.
  2. If the above is not found, source selection falls back to the first source with a deliveryType of HLS.
  3. If no such source is found, it falls back to the source with a deliveryType of MP4 and a bitrate closest to 256 kBps.

Once a source is found, the implementation continues as follows:

  1. If found, the selected source will be emitted with a response to the SELECT_SOURCE event.
  2. By default, the VideoPlaybackController handles the SELECT_SOURCE response, by emitting a SET_SOURCE event.
  3. The VideoDisplayComponent or a subclass handles the SET_SOURCE event by loading the URL into the underlying player (ExoPlayer or MediaPlayer).
  4. When playback begins, the underlying player is responsible for adapting the bitrate with HLS and DASH content. With HLS, the underlying player starts with the first bitrate listed in the master manifest.

When using the default transcode settings, the first HLS source should be the master m3u8 playlist that points to all of your individual sources (renditions).

Setting HLS sources

It is possible to customize source selection at the app level, to filter out any undesired delivery types before the SDK’s default source selection policy is invoked. To do this, you would modify the source collections that are set into the Video object from the Playback API’s JSON response.

This example uses only HLS sources:

catalog.findVideoByReferenceID(videoReferenceId, new com.brightcove.player.edge.VideoListener() {
	public void onVideo(Video video) {
	 sourceSelectionFilter(DeliveryType.HLS, video);

And the sourceSelectionFilter() method would look like this:

public static void sourceSelectionFilter(@NonNull DeliveryType deliveryTypeFilter, @NonNull Video video) {
 if (video.getSourceCollections().containsKey(deliveryTypeFilter)) {
   // Only remove the other delivery types if the desired type is in our Source collections
   for (DeliveryType deliveryType : DeliveryType.values()) {
     if (!deliveryType.equals(deliveryTypeFilter)) {