Code example for MediaPlayer

Methods: setLoopingsetOnCompletionListenersetVolume

0
		setVolume(leftVol, rightVol);
		isComplete = false;
		final ManagedMediaPlayer mmp = this;
 
		if (loop < 0) {
			mp.setLooping(true);
		} else if (loop >= 0) {
			this.loopsLeft = loop;
			mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
				@Override public void onCompletion(MediaPlayer mp) {
					if (--mmp.loopsLeft > 0) {
						mp.seekTo(0);
						mp.start();
					} else { 
						mmp.setComplete();
					} 
				} 
			}); 
		} 
	} 
 
	public ManagedMediaPlayer setMediaPlayer(MediaPlayer mp) {
		this.mp = mp;
		return this;
	} 
 
	public void setVolume(float leftVol, float rightVol) {
		if (mp != null)
			mp.setVolume((float)leftVol, (float)rightVol);
		this.leftVol = leftVol;
		this.rightVol = rightVol;
	} 
 
	public int getDuration() {