Android MediaPlayer失败,状态为0x64

时间:2013-07-28 13:27:00

标签: android android-mediaplayer fileinputstream

我使用以下代码:

          try {
            File f = new File(getVideoUrl(listVideoUrls.get(0)));
            Log.d("MediaPlayer","Fexists?"+f.exists());
            MediaPlayer pl = new MediaPlayer();
            FileInputStream fi = new FileInputStream(f);
            pl.setDataSource(fi.getFD());
            pl.prepare();
            pl.start();
            Log.d("MediaPlayer","MediaPlayer startet.");
          } catch (Exception e) { alert(e.getMessage()); }

但它失败了消息

  

android mediaplayer准备失败状态0x64

我不明白为什么。该文件存在(file.exists()为true),位于/Android/obb/de.blub.kaese/video.mp4

1 个答案:

答案 0 :(得分:0)

尝试release()方法

所以请尝试以下代码

try {
    File f = new File(getVideoUrl(listVideoUrls.get(0)));
    Log.d("MediaPlayer","Fexists?"+f.exists());
    MediaPlayer pl = new MediaPlayer();
    pl.setOnCompletionListener(new OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            mp.release();
        }
    });
    FileInputStream fi = new FileInputStream(f);
    pl.setDataSource(fi.getFD());
    pl.prepare();
    pl.start();
    Log.d("MediaPlayer","MediaPlayer startet.");
} catch (Exception e) { alert(e.getMessage()); }