i tried to stream an audio from url and its working fine. The url is playing on background also when i quit the application. But i cant able to stop it when i enter my app again how could i stop. Help is appreciated.
Asked
Active
Viewed 904 times
2 Answers
2
Put this in your main activity (or wherever you placed your player):
protected void onPause() {
super.onPause();
// Put your media player object here
mp.pause();
}
That should stop your music whenever you leave your activity.

Sander van't Veer
- 5,930
- 5
- 35
- 50
-
@ sander i know this pause method ...what i asked is the music is playing in background when resume my application again after my exit i cant able to stop with stop button....As how android music player does...? – user1051599 Dec 05 '11 at 12:02
-
onPause is not called when HOME button is pressed. One should use onUserLeaveHint() for that case. – Vladimir Ivanov Mar 23 '12 at 08:45
0
In your onBackPressed method write mp.stop() and then mp=null where mp is your mediaplayer instance...

Prashant Kumar
- 134
- 1
- 2
- 9