Android: Understanding the BrightcovePlayer class

Product(s)
Brightcove Player
Video Cloud
Role(s)
Device SDK Developer
Task(s)
Develop with the Native SDKs
SDK
Get Started
Android

In this topic, you will learn about the BrightcovePlayer class and how it provides basic lifecycle management.

 

Using the BrightcovePlayer class

The BrightcovePlayer class is a basic Activity, which wraps a BrightcoveExoPlayerVideoView and sets up an EventLogger and default MediaController . It implements basic lifecycle management and full screen logic. It is meant to be subclassed.

At a minimum the onCreate() method should be overridden with logic to wire up the BrightcoveExoPlayerVideoView variable to the layout.xml file. For example:

brightcoveVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view);

If you want to combine the Brightcove Player with other design elements in your layout, you may choose to use the BrightcovePlayerFragment . This is useful when designing for a tablet or larger screen, which has more room to combine UI components.

Lifecycle management

It is best practice to start with either the BrightcovePlayer activity or the BrightcovePlayerFragment , since these provide default lifecycle management implementation, including the following:

  • When a user pauses the app, the class keeps track of where they stopped.
  • When your app comes back from the background, the class remembers whether the video was playing or not, and restart playback where it left off.
  • If your app is killed due to memory issues, the class will seek to time in video to where it was.
  • An event logger is setup, which logs all events to logcat. This can be helpful for debugging.
  • The class dispatches events to communicate with plugins.
 

Now that you have an activity, you are ready to choose a video view, as detailed in the next document.