Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top