Internet Radio Stream Using ExoPlayer v2

I used EXOPlayer v1.5.6to play Mp3/AACAudioStream, but there are many drawbacks in this version.

I decided to switch to v 2.0.2, but I can’t find the documentation to play only Audio Stream. Please help.

+4
source share
1 answer

Here is the developer guide for the new version of ExoPlayer - link .

You can play the stream from the URI as follows:

TrackSelector trackSelector = new DefaultTrackSelector(
    new Handler(),
    new AdaptiveVideoTrackSelection.Factory(
        new DefaultBandwidthMeter()
    )
);
mediaPlayer = ExoPlayerFactory.newSimpleInstance(
    getApplicationContext(),
    trackSelector,
    new DefaultLoadControl()
);
MediaSource source = new ExtractorMediaSource(
    yourURI,
    new OkHttpDataSourceFactory(
        new OkHttpClient(),
        userAgent,
        null
    ),
    new DefaultExtractorsFactory(),
    null,
    null
);
mediaPlayer.prepare(source);
mediaPlayer.setPlayWhenReady(true);
+3
source

Source: https://habr.com/ru/post/1662254/


All Articles