Problem Stopping MediaPlayer

All your problems with Audio, Video and Images.

Problem Stopping MediaPlayer

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

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?

Posts: 8
Joined: Fri May 21, 2010 7:42 am


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.
Master Developer
Master Developer
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA


Return to Multimedia Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 15 guests