Home Android: How to stop other active media players?
Reply: 0

Android: How to stop other active media players?

user4488 Published in September 20, 2018, 1:12 pm

I'm trying to create a music player. My application has 2 players -

(a) plays songs from the memory

(b) plays online music streams using URLs

The home/default activity of my app is (a). For player (b) there is a separate activity.

Issue is when user presses the play button in activity (b) to play the URL stream, the track from the memory gets played.

It seems like MediaPlayer from activity (a) is still active.

So I want:

  • If user presses the play button, all other media player gets stopped.

    Is there any way to get reference of other media players; Check if they are active; If yes, then stop them.

From a vague perspective, I thought this can be done by sending a broadcast to the Service of activity (a), and make a function there which will listen it and stop the player.

But it seems a bit brute to me & also how should I get the reference of the player in (a).

Hope I've cleared my doubt.

Please suggest.

Thank You

share|improve this question

1 Answer 1

active oldest votes
up vote 5 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.544394 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO