Code example for MediaPlayer: Playing audio and video

Methods: setOnBufferingUpdateListenersetOnCompletionListenerstart

0
		return duration;
	} 
 
	public void onPrepared(MediaPlayer mPlayer) {
		if (isPlaying) {
			mPlayer.setOnCompletionListener(this);
			mPlayer.setOnBufferingUpdateListener(new OnBufferingUpdateListener()
			{ 
				public void onBufferingUpdate(MediaPlayer mPlayer, int percent)
				{ 
					/* TODO: call back, e.g. update outer progress bar */ 
					Log.d("AudioOnBufferingUpdate", "percent: " + percent); 
				} 
			}); 
			mPlayer.start();
		} 
	} 
 
	public boolean onError(MediaPlayer mPlayer, int arg1, int arg2) {
		Log.e("AUDIO onError", "error " + arg1 + " " + arg2);
		return false;