我尝试使用exoplayer的简单实现。此变体不会缓冲后向流。 getDuration()
随时返回-1。并且任何参数的seekTo()
都没有移动流。如何正确缓冲结果,并使用seekTo()
?
int RENDERER_COUNT = 1; //since you want to render simple audio
int minBufferMs = 1000;
int minRebufferMs = 5000;
exoPlayer=ExoPlayer.Factory.newInstance(RENDERER_COUNT,minBufferMs,minRebufferMs);
int BUFFER_SEGMENT_SIZE = 64 * 1024;
int BUFFER_SEGMENT_COUNT = 256;
Uri radioUri = Uri.parse(url2);
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
DataSource dataSource = new DefaultHttpDataSource(userAgent, null, null);
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
ExtractorSampleSource extractorSampleSource = new ExtractorSampleSource(radioUri, dataSource, allocator, BUFFER_SEGMENT_COUNT*BUFFER_SEGMENT_SIZE);
MediaCodecAudioTrackRenderer audioTrackRenderer = new MediaCodecAudioTrackRenderer(extractorSampleSource,MediaCodecSelector.DEFAULT);
exoPlayer.prepare(audioTrackRenderer);
exoPlayer.setPlayWhenReady(true);
playerControl=new PlayerControl(exoPlayer);