Mux

The Mux Developer Hub

Welcome to the Mux developer hub. You'll find comprehensive guides and documentation to help you start working with Mux as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Brightcove SDK for Android

Brightcove's native SDK for Android has support for both the native MediaPlayer as well as ExoPlayer. In the case that you utilize ExoPlayer (via a class such as BrightcoveExoPlayerVideoView), monitoring basic video playback is relatively simple.

You will need to refer to Integration Guide: Android for more detailed information, but Brightcove-specific details are included below.

Requirements

  • Brightcove SDK for Android 6.x
  • ExoPlayer-based Brightcove Player (e.g. BrightcoveExoPlayerVideoView)

Integration Instructions

Brightcove's SDK for Android encapsulates an underlying SimpleExoPlayer instance, which makes integrating Mux with Brightcove's possible. In order to integrate, you need to create an instance of MuxStats for each new video loaded into the player. This is best done by listening for the didSetVideo event that the EventEmitter emits.

Brightcove's current Android SDK (6.2.x) uses ExoPlayer r2.7.x, so you should include the appropriate AAR file from our releases page and in our Integration Guide: Android.

Note: didSetVideo is used in order to get the updated Video in the case that a playlist of Videos, so that you can retrieve the updated metadata.

// MainFragment.java (or MainActivity.java, wherever
// you have access to your `BrightcoveExoPlayerVideoView`

import com.mux.stats.sdk.core.model.CustomerPlayerData;
import com.mux.stats.sdk.core.model.CustomerVideoData;
import com.mux.stats.sdk.muxstats.MuxStatsExoPlayer;
  
public class MainFragment extends BrightcovePlayerFragment implements EventListener {

  public static final String TAG = MainFragment.class.getSimpleName();
  private MuxStatsExoPlayer muxStatsExoPlayer;

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View result = inflater.inflate(R.layout.fragment_main, container, false);
    baseVideoView = (BrightcoveExoPlayerVideoView) result.findViewById(R.id.brightcove_video_view);
    super.onCreateView(inflater, container, savedInstanceState);
    baseVideoView.getEventEmitter().on("didSetVideo", this);
    
    // Set up your videos for playback here
    Video video = Video.createVideo("https://path/to/video.mp4", DeliveryType.HLS);
    
    baseVideoView.add(video);
    baseVideoView.start();
    return result;
  }
  
  @Override
  public void processEvent(Event event) {
    ExoPlayerVideoDisplayComponent videoDisplayComponent = (ExoPlayerVideoDisplayComponent) baseVideoView.getVideoDisplay();
    Video video = baseVideoView.getCurrentVideo();
    SimpleExoPlayer exoPlayer = (SimpleExoPlayer) videoDisplayComponent.getExoPlayer();

    CustomerPlayerData customerPlayerData = new CustomerPlayerData();
    customerPlayerData.setPropertyKey("EXAMPLE_PROPERTY_KEY");
    CustomerVideoData customerVideoData = new CustomerVideoData();
    customerVideoData.setVideoTitle(video.getId());

    if (muxStatsExoPlayer != null) {
      muxStatsExoPlayer.release();
      muxStatsExoPlayer = null;
    }

    muxStatsExoPlayer = new MuxStatsExoPlayer(exoPlayer, "demo-player", customerPlayerData, customerVideoData);
    Point size = new Point();
    ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(size);
    muxStatsExoPlayer.setScreenSize(size.x, size.y);
    muxStatsExoPlayer.setPlayerView(baseVideoView); 
  }
}

Known Issues

  • Due to the implementation of the various listeners within ExoPlayer (e.g. the lack of chaining) and Brightcove listening for certain events, there will be no Video Quality metrics calculated. This is being investigated, but will require an additional update from Brightcove.

Updated 11 months ago

Brightcove SDK for Android


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.