Attention: This post may be outdated. It explained Exoplayer v1.x. In v2.x there were many changes to the API. I updated my example mediaplayer app with controls Github page to Exoplayer 2.

What is Exoplayer?

A few weeks ago i needed to implement a video player in an app. At first i used the standard MediaPlayer class from Android. There were enough example projects and it was easy to code a little player, but after a few days i read about that this class isn’t really capable of playing adaptive streaming formats like Dash or HLS. So, to be ready for future projects i took a look at ExoPlayer.

ExoPlayer is an Android Library from Google introduced at Google IO 2014. Google uses it in their Youtube app and in the Google Play Movie app. Periscope is also using it. It is much more extensible and customizable than MediaPlayer, but you also need to write more code to be able to play Video/Audio with.

There is a DemoApp in the Github Repo, but at first it was hard for me to figure out what was really necessary to play a simple mp4 file.


The advantages from the Google Github Guide
ExoPlayer has a number of advantages over Android’s built in MediaPlayer:

  • Support for Dynamic Adaptive Streaming over HTTP (DASH) and SmoothStreaming, neither of which are are supported by MediaPlayer (it also supports HTTP Live Streaming (HLS), MP4, MP3, WebM, M4A, MPEG-TS and AAC).
  • Support for advanced HLS features, such as correct handling of #EXT-X-DISCONTINUITY tags.
  • The ability to customize and extend the player to suit your use case. ExoPlayer is designed specifically with this in mind, and allows many components to be replaced with custom implementations.
  • Easily update the player along with your application. Because ExoPlayer is a library that you include in your application apk, you have control over which version you use and you can easily update to a newer version as part of a regular application update.
  • Fewer device specific issues.


The only disadvantage is that the earliest API level is level 16. But don’t think that that is really a problem because below that level there are only 4.9 % Android devices.

How to :

integrate in Android Studio project?
you can import the ExoPlayer in your build.gradle file

compile ''

X.X.X stands for the wanted version
You can see the lastet release HERE

prepare player?
I figured out that this the only code you need to set up the player. I’m not sure what the perfect buffer and renderer sizes are, but with this values it should work.

If you are looking for an example project.
I created a simple mediaplayer app with controls that you can find at my Github page

start playback?

stop playback?

exoPlayer.sendMessage(audioRenderer, MediaCodecAudioTrackRenderer.MSG_SET_VOLUME, 0f);

turn sound on again?
exoPlayer.sendMessage(audioRenderer, MediaCodecAudioTrackRenderer.MSG_SET_VOLUME, 1f);

skip to position xy?

Example Project

If you are looking for an example project.
I created a simple mediaplayer app with controls that you can find at my Github page

Building Periscope for Android