Only way you can actually stop it is to do so through the MediaPlayer...
unless I have missed something.

You can *mute* the audio by calling the setStreamMute method - but can't
stop it.  I can see why it works like this, too - there's no reason why it
shouldn't work like this.

I have been running into this in something I was working on - my app needed
to detect if music was playing.  Since it was started by the music app,
there's no way for me to get to the MediaPlayer instance that it holds.

If you were the one who initially created the MediaPlayer instance, then
Marco is correct - you should be holding onto that reference so you can
determine when to stop the audio.  Otherwise, you're out of luck :-(
-Rob

On Sat, May 23, 2009 at 12:57 AM, iDeveloper <ideveloper...@gmail.com>wrote:

> Thanks.
> And how do I stop the audio from playing if isMusicActive() returns true?
> Do I have to use the MediaPlayer instance? But the instance won't be in
> memory any longer as the activity has been exited once and a new instance of
> the activity created in order to come back.
>
> Thanks again.
>
>
>
> On 22-May-09, at 9:45 PM, Rob Franz wrote:
>
> You can detect whether audio is playing by getting a reference to
> AudioManager and calling isMusicActive()...
> -Rob
>
> On Fri, May 22, 2009 at 11:04 AM, Marco Nelissen <marc...@android.com>wrote:
>
>> On Thu, May 21, 2009 at 9:41 PM, iDeveloper <ideveloper...@gmail.com>wrote:
>>
>>>  Hi
>>>
>>> I am using a MediaPlayer instance in order to stream audio files from an
>>> Internet location. The audio player is in a separate activity. The user can
>>> select from a list of audio files and come to this activity which plays the
>>> audio.
>>>
>>> Now the user might go back to the previous activity (with the list) and
>>> select another audio file. In this case, I want to stop any other audio that
>>> is playing and start playing the new audio which was selected.
>>>
>>> Is there any way I can know whether an audio file is playing without
>>> having to hold on to the MediaPlayer object?
>>>
>>
>> No, and you *should* hold on to the MediaPlayer object, because if you
>> don't, it can be garbage collected at any time, at which point playback
>> would stop.
>>
>>
>>
>>
>
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to