在 ExoPlayer 实例中,尝试播放 ogg 文件时出现以下错误:
6541-6594/com.example.android.bluetoothchat E/ExoPlayerImplInternal﹕ Internal track renderer error.
com.google.android.exoplayer.ExoPlaybackException: com.google.android.exoplayer.extractor.ExtractorSampleSource$UnrecognizedInputFormatException:
None of the available extractors (WebmExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, TsExtractor) could read the stream.
at com.google.android.exoplayer.MediaCodecTrackRenderer.maybeThrowError(MediaCodecTrackRenderer.java:782)
at com.google.android.exoplayer.ExoPlayerImplInternal.incrementalPrepareInternal(ExoPlayerImplInternal.java:274)
at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:197)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
Caused by: com.google.android.exoplayer.extractor.ExtractorSampleSource$UnrecognizedInputFormatException: None of the available extractors (WebmExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, TsExtractor) could read the stream.
at com.google.android.exoplayer.extractor.ExtractorSampleSource$ExtractorHolder.selectExtractor(ExtractorSampleSource.java:806)
at com.google.android.exoplayer.extractor.ExtractorSampleSource$ExtractingLoadable.load(ExtractorSampleSource.java:737)
at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:209)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
这是代码:
private void playExoPlayer(){
exoPlayer = ExoPlayer.Factory.newInstance(1);
// sample from vorbis.com/music/
String path = "/sdcard/Download/epoq.ogg";
if (new File(path).exists()) {
// do something if it exists
Toast.makeText(MainActivity2.this, "File " + path + " exists.", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MainActivity2.this, "Error: " + path + " doesn't exist", Toast.LENGTH_LONG).show();
// File was not found
}
Uri pathUri = Uri.parse(path);
com.google.android.exoplayer.upstream.DataSource dataSource = new FileDataSource();
DataSpec dataSpec = new DataSpec(pathUri);
try {
dataSource.open(dataSpec);
} catch (IOException e) {
e.printStackTrace();
}
WebmExtractor extractor = new WebmExtractor();
try {
extractor.sniff(new DefaultExtractorInput(dataSource,0, 64*1024 ));
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
SampleSource sampleSource = new ExtractorSampleSource(pathUri, dataSource, new DefaultAllocator(64*1024), 10485760);
TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
exoPlayer.prepare(audioRenderer);
exoPlayer.setPlayWhenReady(true);
ExoPlayer 版本 1.4.2 over Grandle 编译compile com.google.android.exoplayer:exoplayer:r1.4.2'
Android sdk 22. 我有这个问题,不知道怎么解决。使用默认的 android mediaPlayer 时我没有问题。
有任何想法吗?