Exoplayer 库对我来说似乎很复杂。谁能帮助我如何使用 exoplayer 库流式传输广播电台 url?我尝试使用 MediaPlayer ,它工作正常,但花了很多时间来准备。这是我尝试过的。
exoPlayer = ExoPlayer.Factory.newInstance(RENDERER_COUNT);
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
DataSource dataSource = new DefaultUriDataSource(getApplicationContext(), null, userAgent);
Mp3Extractor extractor = new Mp3Extractor();
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
uri, dataSource, extractor, allocator, BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
exoPlayer.prepare(audioRenderer);
exoPlayer.setPlayWhenReady(true);
我不明白如何获取 userAgent 以及它的含义是什么?