tags:

views:

25

answers:

1

I have created two activities say A and B. Activity A lists list of songs. When we press in any of these songs, the activty B will be called by using startActivity(). Now the activity B will start one thread to create and start mediaplayer with selected song and also show song progress. Everything works fine if we press the back button in activity B,obviously, we will come to activity A and the media player never stops the playing, this is also fine. My problem is after pressing the back button if we select another song,the activity B will be called, then another instance of media player object will be created instead of stopping previously running media player object..So anyone just tell me how can i stop that media player object??? Thanks in advance

A: 

Give this a try :

you can release the previously captured media player object in onStop method of Activity B.

While pressing back button this will released the media player object.

success_anil
Thanks for your reply. My intention is to run the song if we press back or home button but i should stop currently running song when we select another song in activity A.
Venu Gopal
ok.. then in this case .. what you can do In your Activity A that has list of songs while selecting the particular song you can release the previously owned MediaPlayer object ... Keep the reference of MediaPlayer class in Activity A too.
success_anil
thanx for your suggestions..i will do like that and intimate you the result
Venu Gopal
hi success_anil..its very long time to touch you. I followed your technique as declared mediaplayer object statically, check before initializing it whether it is playing or not, if it is playing i reset the mediaplayer object and then initialized it with new song. Now it is working fine.
Venu Gopal
Gr8 To know .. Please accept my anwser.
success_anil
how can i do here???
Venu Gopal