Ogg文件:ExoplayerNone的可用提取器(...)可以读取流。

时间:2015-08-28 21:26:00

标签: android exoplayer

在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而不是Grandle编译compile com.google.android.exoplayer:exoplayer:r1.4.2'

Android sdk 22.我有这个问题而且我不知道如何解决它。使用默认的android mediaPlayer时没有问题。

有什么想法吗?

0 个答案:

没有答案