title: Unable to to create media player with java.io.IOException: setDataSourceFD failed.: status=0x80000000 in 2.3.3 android tablet
body: <blockquote>
    <p>hello, i am new in android please help me, my audio file format is correct .mp4 and mp3, then also sometime its give me this error java.io.IOException: setDataSourceFD failed.: status=0x80000000 or sometime java.lang.NullPointerException.</p>
  </blockquote>
  
  <pre><code>public class Music implements OnCompletionListener    {
  
     public static boolean isPlaying=false;
  
     public static   MediaPlayer mp=null;
  
  public static void playGeneric(int name, final ImageButton button,final ImageButton pervious,Context context) {
  
      button.setEnabled(false);
      button.setClickable(false);
      pervious.setEnabled(false);
      pervious.setClickable(false);
          try{
              if(isPlaying==true)
              {
                  stopplaying();
              }
              if(isPlaying==false)
              {}
  
                mp = MediaPlayer.create(context, name);
                  mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                      @Override
                      public void onPrepared(MediaPlayer arg0) {
  
                          mp.start(); 
                          isPlaying=true;
  
                      }
  
                  });
            mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
  
                  @Override
                  public void onCompletion(MediaPlayer mp) {
                      // TODO Auto-generated method stub
  
                      mp.release();
                      isPlaying=false;
                      System.out.println("Object released");
                      button.setEnabled(true);
                      button.setClickable(true);
                      pervious.setEnabled(true);
                      pervious.setClickable(true);
                  }
              });
  
  
  
  
      } catch (IllegalStateException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }catch (SecurityException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          e.getMessage();
      } catch (NullPointerException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          e.getMessage();
      }
  
  }
  
  public static void stopplaying() {
          if (mp != null) {
              mp.stop();
              mp.release();
              mp = null;
          }
  
      }
  </code></pre>
  
  <blockquote>
    <p>see my LogCat</p>
  </blockquote>
  
  <pre><code>10-15 15:36:19.061: E/MediaPlayer(5018): Unable to to create media player
  10-15 15:36:19.061: D/MediaPlayer(5018): create failed:
  10-15 15:36:19.061: D/MediaPlayer(5018): java.io.IOException: setDataSourceFD failed.: status=0x80000000
  10-15 15:36:19.061: D/MediaPlayer(5018):    at android.media.MediaPlayer.setDataSource(Native Method)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at android.media.MediaPlayer.create(MediaPlayer.java:666)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at com.rogerscenter.LearnReadWriteSpell.Utility.Music.playGeneric(Music.java:102)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at com.rogerscenter.LearnReadWriteSpell.LetterCategory.Letter_Lesson1_activity.onClick(Letter_Lesson1_activity.java:702)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at android.view.View.performClick(View.java:2485)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at android.view.View$PerformClick.run(View.java:9153)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at android.os.Handler.handleCallback(Handler.java:587)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at android.os.Handler.dispatchMessage(Handler.java:92)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at android.os.Looper.loop(Looper.java:123)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at android.app.ActivityThread.main(ActivityThread.java:3647)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at java.lang.reflect.Method.invokeNative(Native Method)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at java.lang.reflect.Method.invoke(Method.java:507)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  10-15 15:36:19.061: D/MediaPlayer(5018):    at dalvik.system.NativeStart.main(Native Method)
  10-15 15:36:19.061: W/System.err(5018): java.lang.NullPointerException
  10-15 15:36:19.061: W/System.err(5018):     at com.rogerscenter.LearnReadWriteSpell.Utility.Music.playGeneric(Music.java:103)
  10-15 15:36:19.061: W/System.err(5018):     at com.rogerscenter.LearnReadWriteSpell.LetterCategory.Letter_Lesson1_activity.onClick(Letter_Lesson1_activity.java:702)
  10-15 15:36:19.061: W/System.err(5018):     at android.view.View.performClick(View.java:2485)
  10-15 15:36:19.061: W/System.err(5018):     at android.view.View$PerformClick.run(View.java:9153)
  10-15 15:36:19.061: W/System.err(5018):     at android.os.Handler.handleCallback(Handler.java:587)
  10-15 15:36:19.061: W/System.err(5018):     at android.os.Handler.dispatchMessage(Handler.java:92)
  10-15 15:36:19.061: W/System.err(5018):     at android.os.Looper.loop(Looper.java:123)
  10-15 15:36:19.061: W/System.err(5018):     at android.app.ActivityThread.main(ActivityThread.java:3647)
  10-15 15:36:19.061: W/System.err(5018):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-15 15:36:19.061: W/System.err(5018):     at java.lang.reflect.Method.invoke(Method.java:507)
  10-15 15:36:19.061: W/System.err(5018):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  10-15 15:36:19.061: W/System.err(5018):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  10-15 15:36:19.061: W/System.err(5018):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <blockquote>
    <p>i can't understand sometime its work perfect,sometime not. i Used this
    method in activities static way.</p>
  </blockquote>