Question

I my application I have a background music that plays when the program starts. In menu I want to add option that user have ability to stop or start the music.

How can I know that the music is playing or stop?

Thanks

Was it helpful?

Solution

Could it be that you're playing it using MediaPlayer? If so:

MediaPlayer mp = new MediaPlayer();
mp.setDataSource(PATH_TO_FILE);
mp.prepare();
mp.start();

stop() and pause() work the same as discussed above.

...

To pause playback, call pause(). Resume playback from where you paused with start().

Cut from here.

Checking if music is playing:

mp.isPlaying();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top