Code example for MediaPlayer

Methods: setOnCompletionListener

0
 
	public AudioClip(Context ctx, Uri uri) {
		name = uri.toString();
		 
		mPlayer = MediaPlayer.create(ctx, uri);
		mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){
 
			public void onCompletion(MediaPlayer mp) {
				mPlaying = false;
				if ( mLoop) {
					mp.start();
				} 
			} 
			 
		}); 
	} 
	 
	public synchronized void play () { 
		if ( mPlaying) 
			return;