Android : 如何使用 exoplayer 2.x.x 播放广播 link

Android : How to use exoplayer 2.x.x to stream a radio link

我想通过 android 服务流式传输具有 exoplayer 版本 rc2.x.x 的在线广播。

我一直在努力从所有在线教程中学习,但它们都是 2.x.x 版本之前的,并且其中很多也与视频流相关(我不需要)。

有没有人有很好的教程?

我对 ExoPlayer 了解不深,但我已经准备了这段可以播放 mp3 的代码片段 link。

EXO Player 版本: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);

    }

这篇 link 也可能对您有所帮助: https://medium.com/@emuneee/migrating-from-exoplayer-1-x-to-2-0-58fbda36b46c#.b8joifc36