I do simple small programs in android for my practice. While I am on the way to create a simple player app, I had to face an error which I could not solve.The following is my code.
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class AndrmusiActivity extends Activity {
/** Called when the activity is first created. */
public MediaPlayer playr;
public Button b1;
public Button b2;
public Button b3;
@Override
public void onCreate(Bundle State) {
super.onCreate(State);
setContentView(R.layout.main);
b1= (Button)findViewById(R.id.play);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
playr = MediaPlayer.create(this,R.raw.showme);
playr.start();
}
});
b2= (Button)findViewById(R.id.Pause);
b2.setOnClickListener(new OnClickListener() {
public void onClick(View v1) {
playr.pause();
}
});
b3=(Button)findViewById(R.id.Stop);
b3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
playr.stop();
playr.reset();
}
});
}
}
Now I faced the error at play method at the line
playr = MediaPlayer.create(this,R.raw.showme);
Could any one please help me in this aspect. Thanks in adv