MusicPlayer Pause and Start from it the start

I am developing music application .

I want to pause the player and when I go for resume it will start it from the that point.

public class Music {

    private static MediaPlayer mp = null;

    public static void play(Context context,int resource){
        mp = MediaPlayer.create(context, resource);

    static void stop(Context context) {
        if(mp != null){
            mp = null;


public class SMusicActivity extends Activity {

    public void onCreate(Bundle savedInstanceState){

        Button btnplay = (Button)findViewById(;
        btnplay.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

        Button btnstop = (Button)findViewById(;
        btnstop.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

    protected void onResume() {

    protected void onPause() {

I want to use stop button as Pause and play . I did coding for it but as you know I didn't get perfect one ..So How can I make operation like Play and Pause into this.


Get rid of your static Music Facade. Use a real MediaPlayer in your activity and

  • instanciate it only once (onCreate)
  • put it to play and pause when buttons are clicked
  • check with mediaPlayer.isPlaying() that you can actually play or pause the player. There is a state diagram to respect when using this object, see the javadoc for further details of states and allowed transitions from specific states.

Need Your Help

App won't install on iOS 7

ios ios7 installation install adhoc

I'm trying to send an app to my client so he can install it on his iPhone. For some reason, when he syncs it, it just says "Installing..." and gets stuck there. Does anyone know what's going on?

java program to group the data in excel by a specific name using apache poi?

java excel apache-poi

This is my whole program to extract data from excel sheet and sort them. After rectifying the mistakes there is still problem in the code. It is executing fine but displaying nothing Can someone fi...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.