Brightcove Native SDK with ExoPlayer 2
Tech Talk
If you are using the Brightcove Native Player SDK for Android, it is very likely you are currently using the Google ExoPlayer framework for your video playback. In 2016, the Google ExoPlayer team released the second major version of the player, doing some major refactoring in the code. We then decided to give it some time before jumping onto the ExoPlayer 2 ship, so that the code would be more stable by the time of the upgrade.
In 2017 we evaluated ExoPlayer 2 and concluded it was time to make the upgrade, which will make it a great addition to the Brightcove SDK and its users.
Upgrading to ExoPlayer 2
When upgrading to ExoPlayer 2, we made a decision to keep both ExoPlayer versions in the Brightcove Native Player SDK for Android, so that you can upgrade to the SDK v6.0.1+ with minimal effort while keeping the legacy player.
You can start exploring ExoPlayer 2 by modifying your build.gradle
file to replace compile project(':players:exoplayer')
with compile project(':players:exoplayer2')
in the dependencies block.
You might be already familiar with the architectural changes made by the Google ExoPlayer team in the second version of their player, but if not, you should know the refactoring was significant with respect to the first version and there were a lot of breaking changes. Some public facing classes were renamed, some others were removed and there were several additions. You can check ExoPlayer 2 - New package and class names to know more about this.
A lot of effort has been taken to manage these architectural changes in the Brightcove Native Player SDK for Android, in order make the upgrade process to ExoPlayer 2 as effortless as possible. If your application is using only the Brightcove classes, the effort to upgrade should be minimal. However, if you are using any exposed ExoPlayer legacy classes, or some of the ExoPlayerVideoDisplayComponent
internal listeners, which depend on ExoPlayer callbacks, it is likely you will encounter some breaking changes.
If you encounter any errors, please check the breaking changes section of the Migrating to ExoPlayer 2 Framework document.
Benefits of Upgrading to ExoPlayer 2
The ExoPlayer 2 in the Brightcove Native SDK for Android offers the same features as with the legacy ExoPlayer. That includes easy Video On-Demand (VOD) playback with support for multiple audio tracks and closed captions such us WebVTT and EIA-608, Widevine Modular protected content playback, client-side advertising with Google Interactive Media Ads (IMA) and FreeWheel, support for Android TV and Fire TV, Video 360 and Offline playback. It also includes full integration with Brightcove Services like VideoCloud and Dynamic Delivery.
With ExoPlayer 2, the Google ExoPlayer team has added newer features to their framework, improved support for existing features and fixed a lot of bugs, making ExoPlayer 2 more robust and reliable. This enabled us to move away from our forked ExoPlayer version used in the legacy player, where we had a lot of custom code, especially around HTTP Live Streaming (HLS) for VOD and Live playback. Our goal is to keep using the Google ExoPlayer directly, rather than a fork, so that future updates can be applied faster and more frequently.
There have been many improvements and additions in important areas of the ExoPlayer 2 framework.
- Full support for DASH multi-periods.
- Additional crypto schemes for DRM and support for offline licensing.
- Better handling for ID3 malformed metadata is included.
- Better support for WebVTT and EIA608 captions.
- Improvement when seeking forward within buffered content, making it really fast and efficient.
By using the Brightcove Native SDK for Android with ExoPlayer 2, your app will be automatically making use of all these enhancements.
As mentioned above, ExoPlayer has also improved substantially its support for HLS.
- Adding or improving support for HLS tags such as EXT-X-DISCONTINUITY, EXT-X-START, EXT-X-DISCONTINUITY-SEQUENCE and EXT-X-PROGRAM-DATE-TIME.
- Added support for the usage of average bandwidth when available in the HLS master playlist.
- Better support for MPEG-TS in several aspects.
- Several utility methods to identify and work with live content.
- Better handling of the BehindLiveWindowException, an enhancement which has been leveraged by the Brightcove Native Player SDK for Android to provide a better experience with HLS Live.
You can check the full list of additions and fixes in the ExoPlayer 2 library in its release notes.
There are certain other features that you can take advantage of by accessing the ExoPlayer 2 Player object directly. However, you must be aware that when working directly with ExoPlayer 2 classes, the chances of introducing breaking changes to your code increases when new ExoPlayer versions are released. You can access the ExoPlayer instance through the getExoPlayer()
method in the ExoPlayerVideoDisplayComponent
class. We are currently using the SimpleExoplayerInstance
, so you can cast it to this object and use its utility methods, as shown below.
ExoPlayerVideoDisplayComponent displayComponent = (ExoPlayerVideoDisplayComponent) brightcoveVideoView.getVideoDisplay();
ExoPlayer exoPlayer = displayComponent.getExoPlayer();
if (exoPlayer instanceof SimpleExoPlayer) {
SimpleExoPlayer simpleExoPlayer = (SimpleExoPlayer) exoPlayer;
}
One example of a feature you might be interested in could be setting a variable speed playback with ExoPlayer.
If you have not already done so, we strongly suggest that you consider upgrading to ExoPlayer 2, as we have deprecated our support for the legacy ExoPlayer framework.