title: Unable to create media player in Android
body: <p>I have developed a simple apps where the alarm will be started for a given period once the activity is started. I have tried the coding in the emulator and it works. But when I run the application in my phone (Android 2.3.5), the application gets force close. </p>
  
  <p>RemoteAlarmActivity.java</p>
  
  <pre><code>MediaPlayer mp;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      mp = MediaPlayer.create(RemoteAlarmActivity.this, R.raw.music);
      Log.d(this.getClass().getName(), "Alarm Created");
  
      try {
          mp.prepare();
      } catch (IllegalStateException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      mp.start();
      Log.d(this.getClass().getName(), "Alarm Started");
  
      Handler h = new Handler();
      Runnable stopPlaybackRun = new Runnable() {
          public void run(){
              mp.stop();
              mp.release();
          }    
      };
      h.postDelayed(stopPlaybackRun, 20 * 1000);
  }
  </code></pre>
  
  <p>Logcat</p>
  
  <pre><code>11-21 15:27:23.192: E/MediaPlayer(13047): Unable to to create media player
  11-21 15:27:23.292: D/MediaPlayer(13047): create failed:
  11-21 15:27:23.292: D/MediaPlayer(13047): java.io.IOException: setDataSourceFD failed.: status=0x80000000
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.media.MediaPlayer.setDataSource(Native Method)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.media.MediaPlayer.create(MediaPlayer.java:704)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at com.testing.alarm.RemoteAlarmActivity.onCreate(RemoteAlarmActivity.java:21)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.app.ActivityThread.access$1500(ActivityThread.java:135)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.os.Handler.dispatchMessage(Handler.java:99)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.os.Looper.loop(Looper.java:150)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at android.app.ActivityThread.main(ActivityThread.java:4385)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at java.lang.reflect.Method.invokeNative(Native Method)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at java.lang.reflect.Method.invoke(Method.java:507)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
  11-21 15:27:23.292: D/MediaPlayer(13047):   at dalvik.system.NativeStart.main(Native Method)
  11-21 15:27:23.302: D/com.testing.alarm.RemoteAlarmActivity(13047): Alarm Created
  </code></pre>
  
  <p>The attached are part of the coding as well as the logcat. Can someone just help me to point out what is wrong with my coding? thanks...</p>