The ExoPlayer demo app serves two primary purposes:
- To provide a relatively simple yet fully featured example of ExoPlayer usage. The demo app can be used as a convenient starting point from which to develop your own application.
- To make it easy to try ExoPlayer. The demo app can be used to test playback of your own content in addition to the included samples.
This page describes how to get, compile and run the demo app. It also describes how to use it to play your own media.
Getting the code
The source code for the demo app can be found in the
demo folder of our
GitHub project. If you haven’t already done so, clone the project into a
Next, open the project in Android Studio. You should see the following in the Android Project view (the relevant folders of the demo app have been expanded):
Compiling and running
To compile and run the demo app, select and run the
demo configuration in
Android Studio. The demo app will install and run on a connected Android device.
We recommend using a physical device if possible. If you wish to use an emulator
instead, please read FAQ - Does ExoPlayer support emulators? and ensure
that your Virtual Device uses a system image with an API level of at least 23.
The demo app presents of a list of samples (
a sample will open a second activity (
PlayerActivity) for playback. The demo
features playback controls and track selection functionality. It also has an
EventLogger class that outputs useful debug information to the system log.
This logging can be viewed (along with error level logging for other tags) with
Including extension decoders
ExoPlayer has a number of extensions that allow use of bundled software decoders, including VP9, Opus, FLAC and FFMPEG (audio only). The demo app can be built to include and use these extensions as follows:
- Build each of the extensions that you want to include. Note that this is a
manual process. Refer to the
README.mdfile in each extension for instructions.
- In Android Studio’s Build Variants view, set the build variant for the demo
withExtensionsReleaseas shown in Figure 3.
- Compile, install and run the
democonfiguration as normal.
By default an extension decoder will be used only if a suitable platform decoder does not exist. It is possible to indicate that extension decoders should be preferred, as described in the sections below.
Playing your own content
There are multiple ways to play your own content in the demo app.
1. Editing assets/media.exolist.json
The samples listed in the demo app are loaded from
By editing this JSON file it’s possible to add and remove samples from the demo
app. The schema is as follows, where [O] indicates an optional attribute.
Playlists of samples can be specified using the schema:
If required, key request headers are specified as an object containing a string attribute for each header:
2. Loading an external exolist.json file
The demo app can load external JSON files using the schema above and named
according to the
*.exolist.json convention. For example if you host such a
https://yourdomain.com/samples.exolist.json, you can open it in the
demo app using:
*.exolist.json link (e.g., in the browser or an email client) on a
device with the demo app installed will also open it in the demo app. Hence
*.exolist.json JSON file provides a simple way of distributing
content for others to try in the demo app.
3. Firing an intent
Intents can be used to bypass the list of samples and launch directly into
playback. To play a single sample set the intent’s action to
com.google.android.exoplayer.demo.action.VIEW and its data URI to that of the
sample to play. Such an intent can be fired from the terminal using:
Supported optional extras for a single sample intent are:
extension[String] Sample type hint. Valid values: mpd, ism, m3u8
prefer_extension_decoders[Boolean] Whether extension decoders are preferred to platform ones
drm_scheme_uuid[String] Drm scheme UUID if protected
drm_license_url[String] Url of the license server if protected
drm_key_request_properties[String array] Key request headers packed as name1, value1, name2, value2 etc. if protected
adb shell am start to fire an intent, an optional string extra can
be set with
--es extension mpd). An optional boolean extra can
be set with
--ez prefer_extension_decoders TRUE). An optional
string array extra can be set with
--esa drm_key_request_properties name1,value1).
To play a playlist of samples set the intent’s action to
com.google.android.exoplayer.demo.action.VIEW_LIST and use a
array extra instead of a data URI. For example:
Supported optional extras for a playlist intent are:
extension_list[String array] Sample type hints. Entries may be empty or one of: mpd, ism, m3u8
drm_key_request_properties, all as described above