Android: error in media Player
<p>I am working in android. this problem is occured:-</p>

<pre><code>09-29 00:22:40.635: ERROR/MediaPlayer(3462): stop called in state 1
09-29 00:22:40.635: ERROR/MediaPlayer(3462): error (-38, 0)
09-29 00:22:40.635: ERROR/MediaPlayer(3462): Error (-38,0)
</code></pre>

<p>this is the code i am using for creating the mediaPlayer:-
package com.pericent.musicapp;</p>

<pre><code>import android.app.Activity;

import android.media.MediaPlayer;

import android.media.MediaPlayer.OnBufferingUpdateListener;

import android.media.MediaPlayer.OnCompletionListener;

import android.os.Bundle;

import android.os.CountDownTimer;

import android.os.Handler;

import android.util.Log;

import android.view.MotionEvent;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.View.OnTouchListener;

import android.widget.EditText;

import android.widget.ImageButton;

import android.widget.SeekBar;

import com.pericent.musicapp.R;


public class StreamingMp3Player extends Activity implements OnClickListener, OnTouchListener, OnCompletionListener, OnBufferingUpdateListener{

    private ImageButton buttonPlayPause;

    private ImageButton buttonStop;

    private SeekBar seekBarProgress;

    String TAG="StreamingMp3Player";

    //public EditText editTextSongURL;

    Bundle extras;

    String songURL;

    private MediaPlayer mediaPlayer;

    CountDownTimer cntr_aCounter = null;

    private static int mediaFileLengthInMilliseconds = 30000; 
    private final Handler handler = new Handler();


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.musicplayerbar);

        Log.v(TAG,"i starting value of mediaFileLength = "+mediaFileLengthInMilliseconds+" and timer = "+cntr_aCounter);


        initView();
        if(mediaPlayer.isPlaying())

            mediaPlayer.reset();


    }


    private void initView() {
        buttonPlayPause = (ImageButton)findViewById(R.id.ButtonTestPlayPause);

        buttonPlayPause.setOnClickListener(this);


        seekBarProgress = (SeekBar)findViewById(R.id.SeekBarTestPlay);  

        seekBarProgress.setMax(99); // It means 100% .0-99

        seekBarProgress.setOnTouchListener(this);

        mediaPlayer = new MediaPlayer();

        mediaPlayer.setOnBufferingUpdateListener(this);

        mediaPlayer.setOnCompletionListener(this);
    }

    /** Method which updates the SeekBar primary progress by current song playing position*/
    private void primarySeekBarProgressUpdater() {
        seekBarProgress.setProgress((int)(((float)mediaPlayer.getCurrentPosition()/mediaFileLengthInMilliseconds)*100)); 

        if (mediaPlayer.isPlaying()) {

            Runnable notification = new Runnable() {

                public void run() {

                    primarySeekBarProgressUpdater();

                }
            };

            handler.postDelayed(notification,1000);
        }
    }

    @Override

    public void onClick(View v) {

        if(v.getId() == R.id.ButtonTestPlayPause){




            if(!mediaPlayer.isPlaying())
                Log.v(TAG,"media player is not playing");
            else
                Log.v(TAG,"media player is  playing");

            if(!mediaPlayer.isPlaying()){
                mediaPlayer = new MediaPlayer();
                try {
                    mediaPlayer.setDataSource("http://192.168.1.126/MusicApplication/Akon.mp3");


                    mediaPlayer.prepare(); 

                } catch (Exception e) {
                    e.printStackTrace();
                }
                cntr_aCounter = new CountDownTimer(30000, 1000) {
                    public void onTick(long millisUntilFinished) {

                    }

                    public void onFinish() {

                        buttonPlayPause.setImageResource(R.drawable.button_play);
                                            mediaPlayer.stop();

                    }
                };
                mediaPlayer.start();
                cntr_aCounter.start();

                buttonPlayPause.setImageResource(R.drawable.button_pause);
            }else {

                mediaPlayer.reset();

                cntr_aCounter.cancel();
                Log.v(TAG,"----player is paused----");  
                buttonPlayPause.setImageResource(R.drawable.button_play);
            }

            primarySeekBarProgressUpdater();
        }

    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if(v.getId() == R.id.SeekBarTestPlay){
            /** Seekbar onTouch event handler. Method which seeks MediaPlayer to seekBar primary progress position*/
            if(mediaPlayer.isPlaying()){
                SeekBar sb = (SeekBar)v;
                int playPositionInMillisecconds = (mediaFileLengthInMilliseconds / 100) * sb.getProgress();
                mediaPlayer.seekTo(playPositionInMillisecconds);
            }
        }
        return false;
    }



    @Override
    public void onCompletion(MediaPlayer mp) {
         /** MediaPlayer onCompletion event handler. Method which calls then song playing is complete*/
        buttonPlayPause.setImageResource(R.drawable.button_play);

    }

    @Override
    public void onBufferingUpdate(MediaPlayer mp, int percent) {
        /** Method which updates the SeekBar secondary progress by current song loading from URL position*/
        seekBarProgress.setSecondaryProgress(percent);
    }
    @Override
    public void onStop()
    {
        super.onStart();
        mediaPlayer.reset();
    }
}
</code></pre>
