Problem Stopping MediaPlayer

All your problems with Audio, Video and Images.

Problem Stopping MediaPlayer

Postby nicoskk » Fri Sep 02, 2011 8:27 am

Hi,
i have a BroadcastReceiver class that listens for Incoming Calls. When the BroadcastReceiver is called i want to start a Mediaplayer and when its called for a second time the MediaPlayer should be stopped.

I initialize the MediaPlayer in the BroadcastReceiver but when i am trying to get its status (mediaplayer.isPlaying()) i always gives false.

Where should i initialize the MediaPlayer, so i can start and stop playing the sound?

Regards,
Nicos
nicoskk
Freshman
Freshman
 
Posts: 8
Joined: Fri May 21, 2010 7:42 am

Top

Re: Problem Stopping MediaPlayer

Postby jonbonazza » Fri Sep 02, 2011 3:01 pm

Initializing the mediaplayer does not "play" it.

the isPlaying() method determines if its playing or not, not whether or not it is in initialized.

Instead of checking for isPlaying(), try checking whether or not it is null.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 24 guests