我开始使用 ExoPlayer 播放一些音频。一切都很好,直到我遇到一个具有“301 永久移动”重定向的 URL。ExoPlayer2 默认不处理。
我已经看过这个帖子:https ://github.com/google/ExoPlayer/issues/423
他们说将新的“allowCrossDomainRedirects”标志添加到 HttpDataSource 或 UriDataSource。问题是我不使用这些类中的任何一个:
//I am NOT using SimpleExoPlayer because I need a different renderer.
exoPlayer = ExoPlayerFactory.newInstance(renderers, trackSelector, loadControl);
final DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(
context,
Util.getUserAgent(context, applicationInfo.getAppName())
);
// Produces Extractor instances for parsing the media data.
final ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
// This is the MediaSource representing the media to be played.
MediaSource mediaSource = new ExtractorMediaSource(
Uri.parse(media.getUriString()) /* uri */,
dataSourceFactory,
extractorsFactory,
10,
null /* eventHandler */,
null /* eventListener */);
exoPlayer.prepare(mediaSource);
了解 ExtractorMediaSource 如何需要 dataSourceFactory 而不是 DataSource。事实上,我什至在 ExoPlayer2 上找不到类 HttpDataSource 和 UriDataSource。看起来它们已被删除。
因此我找不到添加帖子中提到的标志的方法。有人可以帮助我吗?