How to use MediaPlayer in ANDROID? A simple example.

By | February 25, 2011

MediaPlayer class can be used to play Audio in ANDROID.
See how to do this.

MediaPlayer mp = new MediaPlayer();
mp = MediaPlayer.create(MyClassName.this,songId);
		try {

		} catch (IllegalStateException e) {
		} catch (Exception e) {
			Toast.makeText(Switch.this,e.getMessage() , Toast.LENGTH_SHORT).show();			}

        //Called when the song completes.....
            mp.setOnCompletionListener(new OnCompletionListener() {
  			public void onCompletion(MediaPlayer mp) {

Leave a Reply

Your email address will not be published.