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