2014-07-26 154 views
0

任何人都可以解釋爲什麼我會得到這些錯誤。MediaPlayer無法創建

07-26 13:53:20.169: E/MediaPlayer(10391): Unable to to create media player 
07-26 13:53:20.179: E/SurfaceViewVideoActivity(10391): IOException 
07-26 13:53:20.179: E/SurfaceViewVideoActivity(10391): java.io.IOException: setDataSourceFD failed.: status=0x80000000 

我試圖在名爲'Tiger.mp3'的資產文件夾中播放音頻文件。這裏是我的代碼:

@Override 
    public void surfaceCreated(SurfaceHolder holder) 
    { 
     try 
     { 
      mediaplayer.setDisplay(holder); 
      AssetFileDescriptor afd = getAssets().openFd("Tiger.mp3"); 
      mediaplayer.setDataSource(afd.getFileDescriptor()); 
      mediaplayer.prepare(); 
     } 
catch// 
    } 

類似的問題,通過改變從.WAV到MP3播放音頻文件的格式,但看到我試圖播放的文件解決已經.MP3我是有點困惑。 乾杯!

回答

-2

這是你怎麼玩媒體

private void play(View v) { 
    // TODO Auto-generated method stub 
    try{ 
      myPlayer = new MediaPlayer(); 
      myPlayer.setDataSource(outputFile); 
      myPlayer.prepare(); 
      myPlayer.start(); 


      Toast.makeText(getActivity(), "Start play the recording...", 
        Toast.LENGTH_SHORT).show(); 
     } catch (Exception e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

}