1# ExoPlayer # 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 JCenter. It's also possible to clone the 26repository and depend on the modules locally. 27 28### From JCenter ### 29 30#### 1. Add repositories #### 31 32The easiest way to get started using ExoPlayer is to add it as a gradle 33dependency. You need to make sure you have the Google and JCenter repositories 34included in the `build.gradle` file in the root of your project: 35 36```gradle 37repositories { 38 google() 39 jcenter() 40} 41``` 42 43#### 2. Add ExoPlayer module dependencies #### 44 45Next add a dependency in the `build.gradle` file of your app module. The 46following will add a dependency to the full library: 47 48```gradle 49implementation 'com.google.android.exoplayer:exoplayer:2.X.X' 50``` 51 52where `2.X.X` is your preferred version. 53 54As an alternative to the full library, you can depend on only the library 55modules that you actually need. For example the following will add dependencies 56on the Core, DASH and UI library modules, as might be required for an app that 57plays DASH content: 58 59```gradle 60implementation 'com.google.android.exoplayer:exoplayer-core:2.X.X' 61implementation 'com.google.android.exoplayer:exoplayer-dash:2.X.X' 62implementation 'com.google.android.exoplayer:exoplayer-ui:2.X.X' 63``` 64 65The available library modules are listed below. Adding a dependency to the full 66library is equivalent to adding dependencies on all of the library modules 67individually. 68 69* `exoplayer-core`: Core functionality (required). 70* `exoplayer-dash`: Support for DASH content. 71* `exoplayer-hls`: Support for HLS content. 72* `exoplayer-smoothstreaming`: Support for SmoothStreaming content. 73* `exoplayer-ui`: UI components and resources for use with ExoPlayer. 74 75In addition to library modules, ExoPlayer has multiple extension modules that 76depend on external libraries to provide additional functionality. Some 77extensions are available from JCenter, whereas others must be built manually. 78Browse the [extensions directory][] and their individual READMEs for details. 79 80More information on the library and extension modules that are available from 81JCenter can be found on [Bintray][]. 82 83[extensions directory]: https://github.com/google/ExoPlayer/tree/release-v2/extensions/ 84[Bintray]: https://bintray.com/google/exoplayer 85 86#### 3. Turn on Java 8 support #### 87 88If not enabled already, you also need to turn on Java 8 support in all 89`build.gradle` files depending on ExoPlayer, by adding the following to the 90`android` section: 91 92```gradle 93compileOptions { 94 targetCompatibility JavaVersion.VERSION_1_8 95} 96``` 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.exoplayerRoot = 'path/to/exoplayer' 119gradle.ext.exoplayerModulePrefix = 'exoplayer-' 120apply from: new File(gradle.ext.exoplayerRoot, 'core_settings.gradle') 121``` 122 123You should now see the ExoPlayer modules appear as part of your project. You can 124depend on them as you would on any other local module, for example: 125 126```gradle 127implementation project(':exoplayer-library-core') 128implementation project(':exoplayer-library-dash') 129implementation project(':exoplayer-library-ui') 130``` 131 132## Developing ExoPlayer ## 133 134#### Project branches #### 135 136* Development work happens on the `dev-v2` branch. Pull requests should 137 normally be made to this branch. 138* The `release-v2` branch holds the most recent release. 139 140#### Using Android Studio #### 141 142To develop ExoPlayer using Android Studio, simply open the ExoPlayer project in 143the root directory of the repository. 144