tags:

views:

1595

answers:

2

Hi I'm new to this. My self-teaching project is a small application which plays an audio news stream. To be effective, the application really needs to interrupt any currently playing media players (eg: Last FM, Imeem, music player, Spotify etc).

I don't know what will be playing or what application will be playing it, but I want to ask them all to pause until I've done. Sounds rather bold, I know, but it must be possible, because when there's an incoming call, that's basically what happens.

Can I send a message to all audio players asking them to pause for a moment? Could I spoof an incoming call, just for the time it takes?

Thanks.

A: 

You can try AudioManager.adjustVolume method:

AudioManager audioMan = 
    (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioMan.adjustVolume(AudioManager.ADJUST_LOWER,
    AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
Max Gontar
+2  A: 
Christopher
Thanks Christopher, your advice was spot on. I've actually hijacked, the STREAM_ALARM, which suits my purpose, set it to solo and this has the desired effect. Thanks again.
Graham Macleod
Whoops, not such a good idea, at least not with headphones. Back to VOICE_CALL. Don't seem to need MODE_IN_CALL, at least not so far.
Graham Macleod