1# ExoPlayer <img src="https://img.shields.io/github/v/release/google/ExoPlayer.svg?label=latest"/> 2 3ExoPlayer is an application level media player for Android. It provides an 4alternative to Android’s MediaPlayer API for playing audio and video both 5locally and over the Internet. ExoPlayer supports features not currently 6supported by Android’s MediaPlayer API, including DASH and SmoothStreaming 7adaptive playbacks. Unlike the MediaPlayer API, ExoPlayer is easy to customize 8and extend, and can be updated through Play Store application updates. 9 10## Documentation 11 12* The [developer guide][] provides a wealth of information. 13* The [class reference][] documents ExoPlayer classes. 14* The [release notes][] document the major changes in each release. 15* Follow our [developer blog][] to keep up to date with the latest ExoPlayer 16 developments! 17 18[developer guide]: https://exoplayer.dev/guide.html 19[class reference]: https://exoplayer.dev/doc/reference 20[release notes]: https://github.com/google/ExoPlayer/blob/release-v2/RELEASENOTES.md 21[developer blog]: https://medium.com/google-exoplayer 22 23## Using ExoPlayer 24 25ExoPlayer modules can be obtained from [the Google Maven repository][]. It's 26also possible to clone the repository and depend on the modules locally. 27 28[the Google Maven repository]: https://developer.android.com/studio/build/dependencies#google-maven 29 30### From the Google Maven repository 31 32#### 1. Add ExoPlayer module dependencies 33 34The easiest way to get started using ExoPlayer is to add it as a gradle 35dependency in the `build.gradle` file of your app module. The following will add 36a dependency to the full library: 37 38```gradle 39implementation 'com.google.android.exoplayer:exoplayer:2.X.X' 40``` 41 42where `2.X.X` is your preferred version. 43 44As an alternative to the full library, you can depend on only the library 45modules that you actually need. For example the following will add dependencies 46on the Core, DASH and UI library modules, as might be required for an app that 47only plays DASH content: 48 49```gradle 50implementation 'com.google.android.exoplayer:exoplayer-core:2.X.X' 51implementation 'com.google.android.exoplayer:exoplayer-dash:2.X.X' 52implementation 'com.google.android.exoplayer:exoplayer-ui:2.X.X' 53``` 54 55When depending on individual modules they must all be the same version. 56 57The available library modules are listed below. Adding a dependency to the full 58ExoPlayer library is equivalent to adding dependencies on all of the library 59modules individually. 60 61* `exoplayer-core`: Core functionality (required). 62* `exoplayer-dash`: Support for DASH content. 63* `exoplayer-hls`: Support for HLS content. 64* `exoplayer-rtsp`: Support for RTSP content. 65* `exoplayer-smoothstreaming`: Support for SmoothStreaming content. 66* `exoplayer-transformer`: Media transformation functionality. 67* `exoplayer-ui`: UI components and resources for use with ExoPlayer. 68 69In addition to library modules, ExoPlayer has extension modules that depend on 70external libraries to provide additional functionality. Some extensions are 71available from the Maven repository, whereas others must be built manually. 72Browse the [extensions directory][] and their individual READMEs for details. 73 74More information on the library and extension modules that are available can be 75found on the [Google Maven ExoPlayer page][]. 76 77[extensions directory]: https://github.com/google/ExoPlayer/tree/release-v2/extensions/ 78[Google Maven ExoPlayer page]: https://maven.google.com/web/index.html#com.google.android.exoplayer 79 80#### 2. Turn on Java 8 support 81 82If not enabled already, you also need to turn on Java 8 support in all 83`build.gradle` files depending on ExoPlayer, by adding the following to the 84`android` section: 85 86```gradle 87compileOptions { 88 targetCompatibility JavaVersion.VERSION_1_8 89} 90``` 91 92#### 3. Enable multidex 93 94If your Gradle `minSdkVersion` is 20 or lower, you should 95[enable multidex](https://developer.android.com/studio/build/multidex) in order 96to prevent build errors. 97 98### Locally 99 100Cloning the repository and depending on the modules locally is required when 101using some ExoPlayer extension modules. It's also a suitable approach if you 102want to make local changes to ExoPlayer, or if you want to use a development 103branch. 104 105First, clone the repository into a local directory and checkout the desired 106branch: 107 108```sh 109git clone https://github.com/google/ExoPlayer.git 110cd ExoPlayer 111git checkout release-v2 112``` 113 114Next, add the following to your project's `settings.gradle` file, replacing 115`path/to/exoplayer` with the path to your local copy: 116 117```gradle 118gradle.ext.exoplayerModulePrefix = 'exoplayer-' 119apply from: file("path/to/exoplayer/core_settings.gradle") 120``` 121 122You should now see the ExoPlayer modules appear as part of your project. You can 123depend on them as you would on any other local module, for example: 124 125```gradle 126implementation project(':exoplayer-library-core') 127implementation project(':exoplayer-library-dash') 128implementation project(':exoplayer-library-ui') 129``` 130 131## Developing ExoPlayer 132 133#### Project branches 134 135* Development work happens on the `dev-v2` branch. Pull requests should 136 normally be made to this branch. 137* The `release-v2` branch holds the most recent release. 138 139#### Using Android Studio 140 141To develop ExoPlayer using Android Studio, simply open the ExoPlayer project in 142the root directory of the repository. 143