MediaPlayer: Stop , play back issue

by AndroidUser » Fri, 06 Mar 2009 05:13:42 GMT


Sponsored Links
 When i tried to play the audio button i can ablet to play, pause.

But i am unable to play again once if i stopped. What i did mistake
here could u plz explain



public class PlayAudio extends Activity {

      /** Called when the activity is first created. */

      @Override

      public void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.main);

            final MediaPlayer mp = MediaPlayer.create(getBaseContext
(),

                        R.raw.sunday);



            final Button btnPlayAudio = (Button) findViewById
(R.id.btnPlayAudio);



            btnPlayAudio.setOnClickListener(new OnClickListener()



            {

                  public void onClick(View v) {

                        if (v.getId() == R.id.btnPlayAudio)
{

                              try {

                                    mp.start
();

                              } catch (Exception e) {

                              }

                        }

                  }



            });



            final Button pausePlayAudio = (Button) findViewById
(R.id.pausePlayAudio);

            pausePlayAudio.setOnClickListener(new OnClickListener() {

                  public void onClick(View v) {

                        if (v.getId() == R.id.pausePlayAudio) {

                              mp.pause();

                        }

                  }

            });



            final Button stopPlayAudio = (Button) findViewById
(R.id.stopPlayAudio);

            stopPlayAudio.setOnClickListener(new OnClickListener() {

                  public void onClick(View v) {

                        if (v.getId() == R.id.stopPlayAudio) {

                              mp.stop();

                              mp.release();

                        }

                  }

            });









      }



}


--~--~---------~--~----~------------~-------~--~----~



MediaPlayer: Stop , play back issue

by Marco Nelissen » Fri, 06 Mar 2009 05:33:11 GMT


 It's because you called MediaPlayer.stop() and MediaPlayer.release(),
which stop playback and clean up all resources associated with the
MediaPlayer. You cannot use the MediaPlayer again after release().






--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. G1 Android Phone May Be Unable to Receive Updates

Ga dong.. Magic sama Hero punya RAM/ROM sebesar 288MB/512MB.. sedang G1..
cuma punya RAM/ROM sebesar 192MB/256MB
Romnya magic sama hero 2xnya G1 or Dream :)
CMIIW

--
sent from my G1





Kalo begitu htc magic ama htc hero gak bisa update juga dong, soalnya
kan memory internalnya sama



G1 itu adalah > intern...




--~--~---------~--~----~------------~-------~--~----~

2. How to use requestLocationUpdates to sample GPS based on time only?

Hi,

I would like to use requestLocationUpdates to periodically get a GPS
fix, not based on the actual distance covered.

If I specify the following arguments:
- m_LocationManager.requestLocationUpdates("network", 60000, 0, this):
requestLocationUpdates is called more than every 60000ms. I believe
this is because the min distance covered is 0. This does not work for
me as I want to get updates every minute.
- m_LocationManager.requestLocationUpdates("network", 60000, 100,
this): will not return every 60000ms unless the subject has moved for
at least 100m.

How to use this function so I get updates only based on elapsed time,
not distance covered?

Thanks,
Jean

--~--~---------~--~----~------------~-------~--~----~

3. Experimental Bluetooth Library

4. ListView data binding from XML (REST-RPC request)

5. HTC Hero has multi-touch. SDK support?

6. Drawing in a child View

7. Vertical and Horizontal Scrolling together