title: Error on Android Media player
body: <p>Currently I am working on a music Player. Please help me out with these errors    </p>
  
  <pre><code>public class MainActivity extends Activity {
  
      Button playb,pauseb,stopb;
  
      SeekBar seeker;
      Handler seekhandler;
      MediaPlayer player;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          player=new MediaPlayer();//.create(MainActivity.this, R.raw.spaceman);
  
          //Interface between code and xml
          playb=(Button)findViewById(R.id.play_button);
          stopb=(Button)findViewById(R.id.stop_button);
          pauseb=(Button)findViewById(R.id.pause_button);
          seeker=(SeekBar)findViewById(R.id.seekBar);
  
  
          try {
              player.prepare();
          } catch (IOException e) {
              Toast.makeText(getApplicationContext(),(CharSequence) e,Toast.LENGTH_SHORT ).show();
          }
          //Code for Play Button
          playb.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view){
                  player.stop();
                  player.reset();
                  seeker.setProgress(0);
                  try {
                      player.prepare();
                  } catch (IOException e) {
                      Toast.makeText(getApplicationContext(), (CharSequence) e,Toast.LENGTH_SHORT).show();
  
                  }
                  player.start();
                  seeker.setMax(player.getDuration());
              }
          });
  
  
          //Code for Pause button
          pauseb.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
              player.pause();
              }
          });
  
          //code for Stop button
          stopb.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
               player.reset();
              }
          });
  
  
          //Code for seekbar change listner
          seeker.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
              @Override
              public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
  
              }
  
              @Override
              public void onStartTrackingTouch(SeekBar seekBar) {
  
              }
  
              @Override
              public void onStopTrackingTouch(SeekBar seekBar) {
  
              }
          });
  
          Runnable runnable =new Runnable() {
              @Override
              public void run() {
                  seeker.setProgress(player.getCurrentPosition());
                  seekhandler.postDelayed(this,1000);
  
              }
          };
      }
  }
  </code></pre>
  
  <p>Errors:</p>
  
  <blockquote>
    <p>09-19 20:16:15.342 25242-25242/main.deviac.com.seekbar E/AndroidRuntime: FATAL EXCEPTION: main
                                                                             Process: main.deviac.com.seekbar, PID: 25242
                                                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{main.deviac.com.seekbar/main.deviac.com.seekbar.MainActivity}: java.lang.IllegalStateException
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2452)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
                                                                                 at android.app.ActivityThread.access$900(ActivityThread.java:154)
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                 at android.os.Looper.loop(Looper.java:152)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5497)
                                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                              <strong>Caused by: java.lang.IllegalStateException</strong>
                                                                                 at android.media.MediaPlayer._prepare(Native Method)
                                                                                 at android.media.MediaPlayer.prepare(MediaPlayer.java:1158)
                                                                                 at main.deviac.com.seekbar.MainActivity.onCreate(MainActivity.java:42)
                                                                                 at android.app.Activity.performCreate(Activity.java:6285)
                                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535) 
                                                                                 at android.app.ActivityThread.access$900(ActivityThread.java:154) 
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                 at android.os.Looper.loop(Looper.java:152) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5497) 
                                                                                 at java.lang.reflect.Method.invoke(Native Method) 
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
    09-19 20:16:15.344 25242-25242/main.deviac.com.seekbar D/AppTracker: App Event: crash
    09-19 20:16:28.590 25409-25409/main.deviac.com.seekbar W/System: ClassLoader referenced unknown path: /data/app/main.deviac.com.seekbar-2/lib/arm64
    09-19 20:16:28.669 25409-25409/main.deviac.com.seekbar W/System: ClassLoader referenced unknown path: /data/app/main.deviac.com.seekbar-2/lib/arm64</p>
  </blockquote>
  
  <p>I have kept mp3 file(spaceman) in raw folder which resides in res directory</p>