Question

Here is what I want to achieve in my app: I have 3 menus in the startup page: PLAY , INSTRUCTIONS , HIGH SCORE. I have theme music playing in the background with the help of MediaPlayer object. I just want that the theme music should be playing for the PLAY and INSTRUCTIONS menu, uninterrupted, i.e, if the activity changes from MAIN MENU to INSTRUCTIONS and vice-versa , the music should be playing uninterrupted. But the music should stop as soon as the PLAY activity is started. I don't know the best way to do it, but all I can think of is sending the MediaPlayer object that started the theme music to PLAY's oncreate and stop it there. is there any way to do this?

Was it helpful?

Solution

You want to use a Service to play the music (and to do so off of the main thread). Here are relevant pages on

Services

Media playback

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top