I am trying to play streaming music background and for that I am using music service class below:

```
public class MusicService extends Service implements
        OnErrorListener, MediaPlayer.OnCompletionListener {

    private static final int NOTIFICATION_ID = 1;
    private final IBinder mBinder = new ServiceBinder();
    MediaPlayer mPlayer;
    private int length = 0;
    private Notification mNotification;

    public MusicService() {
    }

    @Override
    public void onCompletion(MediaPlayer mp) {
        mPlayer.stop();
    }

    public class ServiceBinder extends Binder {
        public MusicService getService() {
            return MusicService.this;
        }
    }

    @Override
    public IBinder onBind(Intent arg0) {
        return mBinder;
    }

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

        mPlayer = new MediaPlayer();
        mPlayer.setOnCompletionListener(this);
        mPlayer.setOnErrorListener(this);

        if (mPlayer != null) {
            mPlayer.setLooping(true);
            mPlayer.setVolume(100, 100);
        }

        mPlayer.setOnErrorListener(new OnErrorListener() {

            public boolean onError(MediaPlayer mp, int what, int extra) {

                onError(mPlayer, what, extra);
                return true;
            }
        });
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        // mPlayer.start();
        return START_STICKY;

    }

    public void startMusic(String path) {
        Toast.makeText(this, "pause music", Toast.LENGTH_SHORT).show();
        if (mPlayer.isPlaying()) {
            mPlayer.release();
        }
        try {
            SongController s = (SongController) DBControllerFactory.getController("queue", this);
            Log.d("MusicService", Config.SERVICE_ROOT_URL + "uploads/" + ((Song) s.select()[s.getTotalRows() - 1]).getFile() + ".mp3");
            mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            mPlayer.setDataSource(Config.SERVICE_ROOT_URL + "uploads/" + ((Song) s.select()[s.getTotalRows() - 1]).getFile() + ".mp3");
            mPlayer.prepare();  /////error at here
            mPlayer.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void pauseMusic() {
        Toast.makeText(this, "pause music", Toast.LENGTH_SHORT).show();
        if (mPlayer.isPlaying()) {
            mPlayer.pause();
            length = mPlayer.getCurrentPosition();
        }
    }

    public void resumeMusic() {
        Toast.makeText(this, "resume music", Toast.LENGTH_SHORT).show();
        if (mPlayer.isPlaying() == false) {
            mPlayer.seekTo(length);
            mPlayer.start();
        }
    }

    public void stopMusic() {
        //setUpAsForeground("test");
        Toast.makeText(this, "stop music", Toast.LENGTH_SHORT).show();
        mPlayer.stop();
        mPlayer.release();
        mPlayer = null;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPlayer != null) {
            try {
                mPlayer.stop();
                mPlayer.release();
            } finally {
                mPlayer = null;
            }
        }

    }

    public boolean onError(MediaPlayer mp, int what, int extra) {

        Toast.makeText(this, "music player failed", Toast.LENGTH_SHORT).show();
        if (mPlayer != null) {
            try {
                mPlayer.stop();
                mPlayer.release();
            } finally {
                mPlayer = null;
            }
        }
        return false;
    }

    void setUpAsForeground(String text) {
        Intent openIntent = new Intent(getApplicationContext(), MainScreenActivity.class);
        openIntent.putExtra("action", "opendrawer");
        PendingIntent pi = PendingIntent.getActivity(getApplicationContext(),
                0,
                openIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        mNotification = new Notification();
        mNotification.tickerText = text;
        mNotification.icon = R.drawable.ic_launcher;
        mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
        mNotification.setLatestEventInfo(getApplicationContext(),
                getResources().getString(R.string.app_name), text, pi);
        startForeground(NOTIFICATION_ID, mNotification);
    }
}

```

when first time music is played , it works properly, but second time it gives following error:

```
java.io.IOException: Prepare failed.: status=0x1
 W/System.err﹕ at android.media.MediaPlayer._prepare(Native Method)
 W/System.err﹕ at android.media.MediaPlayer.prepare(MediaPlayer.java:1125)
......

```

but if I remove cache of my app from device It again works properly. so I think it's problem related to cache but I am unable to determine the problem can anyone help me please????