1

我正在使用以下代码:

          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()为真)并位于/Android/obb/de.blub.kaese/video.mp4.

4

1 回答 1

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()); }
于 2013-07-28T13:44:32.143 回答