, ExoPlayer, . , , - Android ExoPlayer. , . .
http, , , - . v1.xx ExoPlayer, v1.5.11:
build.gradle(Module: app) "":
compile 'com.google.android.exoplayer:exoplayer:r1.5.11'
ExoPlayer.Listener
:
...implements ExoPlayer.Listener
http:
private static final int RENDERER_COUNT = 1;
private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
private static final int BUFFER_SEGMENT_COUNT = 256;
private ExoPlayer exoPlayer;
int minBufferMs = 1000;
int minRebufferMs = 5000;
exoPlayer = ExoPlayer.Factory.newInstance(RENDERER_COUNT, minBufferMs, minRebufferMs);
String stream_location = "http://audio_stream_url";
Uri streamUri = Uri.parse(stream_location);
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
String userAgent = Util.getUserAgent(ChicagoPoliceRadioService.this, "ExoPlayer_Test");
DataSource dataSource = new DefaultUriDataSource(ChicagoPoliceRadioService.this, null, userAgent);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
streamUri, dataSource, allocator, BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT);
exoPlayer.addListener(this);
exoPlayer.prepare(audioRenderer);
exoPlayer.sendMessage(audioRenderer, MediaCodecAudioTrackRenderer.MSG_SET_VOLUME, 1f);
exoPlayer.setPlayWhenReady(true);
:
@Override
public void onPlayWhenReadyCommitted() {
}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_READY) {
}
}
@Override
public void onPlayerError(ExoPlaybackException error) {
}
, :
if (exoPlayer != null) {
exoPlayer.stop();
exoPlayer.release();
}
. 100% ExoPlayer. . , 1.5.x ExoPlayer 2.0 , . , , , , Samsung, 30 .