Neeti Gupta
Neeti Gupta

Reputation: 1

I have created my own mediaplayer in android

my problem is when device Mediaplayer is playing any song my Mediaplayer is not stopping.Both Mediaplayer playing song together.

Upvotes: 0

Views: 46

Answers (1)

Piyush
Piyush

Reputation: 1973

When your application needs to output audio such as music or a notification, you should always request audio focus. Once it has focus, it can use the sound output freely, but it should always listen for focus changes.

Use AudioManager to request Audio Focus and implement AudioManager.OnAudioFocusChangeListener to respond to Audio Focus changes.

So listen to audiofocus changes and modify you app accordingly. See the hyperlink for more information.

Upvotes: 1

Related Questions