我一直在嘗試使用ExoPlayer
來傳輸URL
。網址:無法使用ExoPlayer獲取AAC文件的getDuration()
STREAM_URL_1 = 「http://storage.googleapis.com/exoplayer-test-media-0/play.mp3」
STREAM_URL_2 = 「https://s3-ap-southeast-1.amazonaws.com/ok.talk.channels/zakirkhan/Zakir+khan+-+when+my+father+took+my+gf%27s+call.aac」
兩個網址玩,但我沒能拿到getDuration()
爲STREAM_URL_2這是一個。AAC文件。 .mp3的作品。
以下是我該怎麼做。如何獲得第二個URL的getDuration()
。即使seekTo()
不起作用,如果getDuration()
不起作用。
我應該做什麼改變?我需要更改任何Extractor
嗎?
player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, MIN_BUFFER_MS, MIN_RE_BUFFER_MS);
playerControl = new PlayerControl(player);
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
private static final String STREAM_URL = "http://storage.googleapis.com/exoplayer-test-media-0/play.mp3";
uri = Uri.parse(STREAM_URL);
// Build the video and audio renderers.
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
null);
String userAgent = Util.getUserAgent(this, "MyMediaPlayer");
DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent, true);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
null, true);
// Invoke the callback.
TrackRenderer[] renderers = new TrackRenderer[1];
renderers[RadioPlayer.TYPE_AUDIO] = audioRenderer;
player.prepare(renderers);
player.seekTo(0);
player.setPlayWhenReady(true);
是的,你是對的。 AAC文件也是這個問題。但是,當我使用「MediaPlayer」時,可以同時獲得持續時間和尋找位置。這怎麼能被複制? –