ExoPlayer : Streaming remote video in Android

ExoPlayer : Streaming remote video in Android

ExoPlayer is an Android Application level Media Player by Google. It is used for playing media(both audio and video) from local or remote. In this article we will discuss how to play or stream remote video using ExoPlayer.

LIBRARY SET UP for ExoPlayer

First of all, we need to create a new project(ExoPlayerSample here in this article) and then move to MainActivity.java as usual. Before we start implementation we need to add dependency for ExoPlayer.

So, now we move to project-level build.gradle file and include Google and JCenter repositories. It will look like below

Next, we need to add library dependency in app level build.gradle file.

In above section we have used version 2.9.6. But you should check for latest versions while implementing.

Another thing we need to add is INTERNET permission in AndroidManifest.xml. So the Manifest file will look like below


ExoPlayer comes with a default design but it has that much flexibility to add own custom design by maintaining some of it’s default view-ids for same code(Java) of implementation as with default design. But before that we will add view in MainActivity’s design file.


Now it’s time to implement the ExoPlayer in activity. The very first step is to initialise the player. Here we go

In above piece of code we have initialised ExoPlayer using DashMediaSource. DashMediaSource is responsible for playing the manifest at a given Uri which can be static or dynamic. Here SEEK_POSITION is the player’s last played position which is required to store for orientation change, minimising screen etc.

Now we will learn how to release the player while destroying or stopping Activity. This is simplified by ExoPlayer’s release() method which is needed to call where it is required.

The above method can be called in onStop() or onDestroy() methods.


That was a small POC for streaming video using ExoPlayer in Android. You can find full source code from GitHub. We can do much more things with ExoPlayer like

  • Play media using DRM
  • Play local media
  • Stream live video
  • Customise player’s basic design with additional functionalities like minimise, maximise, skip etc.

Source : Github Documentation by Google

If you like this article spread it to inspire us.

Suggested Read : Install Referrer for Android using Google Play Campaign Measurement

Abhishek is a developer cum blogger working more than 6 years. He loves programming especially open stack technologies. He has decent knowledge in Android development, Wordpress, MongoDB, Node.js and so on. Beside this Abhishek finds himself busy in painting, front-end designing.

Follow Abhishek


Campaign measurement install referrer
Install Referrer for Android using Google Play Campaign Measurement


React Native Structure
React Native project structure : A handsome way