mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Deduplicate the network-stacks and customization dev guide pages
PiperOrigin-RevId: 438547078
This commit is contained in:
parent
36376eb941
commit
57a937d72a
1 changed files with 2 additions and 29 deletions
|
|
@ -43,33 +43,7 @@ described below.
|
||||||
|
|
||||||
### Configuring the network stack ###
|
### Configuring the network stack ###
|
||||||
|
|
||||||
ExoPlayer supports Android's default network stack, as well as Cronet and
|
We have a page about [customizing the network stack used by ExoPlayer].
|
||||||
OkHttp. In each case it's possible to customize the network stack for your use
|
|
||||||
case. The following example shows how to customize the player to use Android's
|
|
||||||
default network stack with cross-protocol redirects enabled:
|
|
||||||
|
|
||||||
~~~
|
|
||||||
// Build a DefaultHttpDataSource.Factory with cross-protocol redirects enabled.
|
|
||||||
DataSource.Factory httpDataSourceFactory =
|
|
||||||
new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true);
|
|
||||||
|
|
||||||
// Wrap the DefaultHttpDataSource.Factory in a DefaultDataSource.Factory, which
|
|
||||||
// adds in support for requesting data from other sources (e.g., files,
|
|
||||||
// resources, etc).
|
|
||||||
DefaultDataSource.Factory dataSourceFactory =
|
|
||||||
new DefaultDataSource.Factory(context, httpDataSourceFactory);
|
|
||||||
|
|
||||||
// Inject the DefaultDataSource.Factory when creating the player.
|
|
||||||
ExoPlayer player =
|
|
||||||
new ExoPlayer.Builder(context)
|
|
||||||
.setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory))
|
|
||||||
.build();
|
|
||||||
~~~
|
|
||||||
{: .language-java}
|
|
||||||
|
|
||||||
The same approach can be used to configure and inject HTTP-based
|
|
||||||
`DataSource.Factory` implementations provided by the [Cronet extension] and the
|
|
||||||
[OkHttp extension], depending on your preferred choice of network stack.
|
|
||||||
|
|
||||||
### Caching data loaded from the network ###
|
### Caching data loaded from the network ###
|
||||||
|
|
||||||
|
|
@ -299,8 +273,7 @@ When building custom components, we recommend the following:
|
||||||
ensures that they are executed in order with any other operations being
|
ensures that they are executed in order with any other operations being
|
||||||
performed on the player.
|
performed on the player.
|
||||||
|
|
||||||
[Cronet extension]: https://github.com/google/ExoPlayer/tree/release-v2/extensions/cronet
|
[customizing the network stack used by ExoPlayer]: {{ site.baseurl }}/network-stacks.html
|
||||||
[OkHttp extension]: https://github.com/google/ExoPlayer/tree/release-v2/extensions/okhttp
|
|
||||||
[LoadErrorHandlingPolicy]: {{ site.exo_sdk }}/upstream/LoadErrorHandlingPolicy.html
|
[LoadErrorHandlingPolicy]: {{ site.exo_sdk }}/upstream/LoadErrorHandlingPolicy.html
|
||||||
[media source based playlist API]: {{ site.baseurl }}/media-sources.html#media-source-based-playlist-api
|
[media source based playlist API]: {{ site.baseurl }}/media-sources.html#media-source-based-playlist-api
|
||||||
[asynchronous mode]: https://developer.android.com/reference/android/media/MediaCodec#asynchronous-processing-using-buffers
|
[asynchronous mode]: https://developer.android.com/reference/android/media/MediaCodec#asynchronous-processing-using-buffers
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue