• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ExoPlayer Cronet extension #
2
3The Cronet extension is an [HttpDataSource][] implementation using [Cronet][].
4
5[HttpDataSource]: https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/upstream/HttpDataSource.html
6[Cronet]: https://chromium.googlesource.com/chromium/src/+/master/components/cronet?autodive=0%2F%2F
7
8## Getting the extension ##
9
10The easiest way to use the extension is to add it as a gradle dependency:
11
12```gradle
13implementation 'com.google.android.exoplayer:extension-cronet:2.X.X'
14```
15
16where `2.X.X` is the version, which must match the version of the ExoPlayer
17library being used.
18
19Alternatively, you can clone the ExoPlayer repository and depend on the module
20locally. Instructions for doing this can be found in ExoPlayer's
21[top level README][].
22
23[top level README]: https://github.com/google/ExoPlayer/blob/release-v2/README.md
24
25## Using the extension ##
26
27ExoPlayer requests data through `DataSource` instances. These instances are
28either instantiated and injected from application code, or obtained from
29instances of `DataSource.Factory` that are instantiated and injected from
30application code.
31
32If your application only needs to play http(s) content, using the Cronet
33extension is as simple as updating any `DataSource`s and `DataSource.Factory`
34instantiations in your application code to use `CronetDataSource` and
35`CronetDataSourceFactory` respectively. If your application also needs to play
36non-http(s) content such as local files, use
37```
38new DefaultDataSource(
39    ...
40    new CronetDataSource(...) /* baseDataSource argument */);
41```
42and
43```
44new DefaultDataSourceFactory(
45    ...
46    new CronetDataSourceFactory(...) /* baseDataSourceFactory argument */);
47```
48respectively.
49
50## Links ##
51
52* [Javadoc][]: Classes matching `com.google.android.exoplayer2.ext.cronet.*`
53  belong to this module.
54
55[Javadoc]: https://exoplayer.dev/doc/reference/index.html
56