我想通过 android 服务流式传输具有 exoplayer 版本 rc2.xx 的在线广播。
我一直在尝试从所有在线教程中学习,但它们都在 2.xx 版本之前,其中很多也与视频流相关(我不需要)。
有人有很好的教程吗?
我想通过 android 服务流式传输具有 exoplayer 版本 rc2.xx 的在线广播。
我一直在尝试从所有在线教程中学习,但它们都在 2.xx 版本之前,其中很多也与视频流相关(我不需要)。
有人有很好的教程吗?
我对 ExoPlayer 没有深入的了解,但我准备了这个可以流式传输 mp3 链接的代码片段。
EXO 播放器版本:r2.0.4
private void initMediaPlayer() {
Handler mHandler = new Handler();
String userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:40.0) Gecko/20100101 Firefox/40.0";
Uri uri = Uri.parse("http://feedproxy.google.com/~r/TheCombatJackShow/~5/s_9fWPxLDu0/188058705-thecombatjackshow-the-j-cole-episode.mp3");
DataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory(
userAgent, null,
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
true);
MediaSource mediaSource = new ExtractorMediaSource(uri, dataSourceFactory, Mp3Extractor.FACTORY,
mHandler, null);
TrackSelector trackSelector = new DefaultTrackSelector(mHandler);
DefaultLoadControl loadControl = new DefaultLoadControl();
ExoPlayer exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
//exoPlayer.addListener(this);
exoPlayer.prepare(mediaSource);
exoPlayer.setPlayWhenReady(true);
}
此链接也可以帮助您: https ://medium.com/@emuneee/migrating-from-exoplayer-1-x-to-2-0-58fbda36b46c#.b8joifc36