Code example for MediaPlayer: Playing audio and video

Methods: prepareseekTosetLoopingstartstop

0
		 
		if (mBackgroundMediaPlayer == null){
			Log.e(TAG, "playBackgroundMusic: background media player is null");
		} else {		 
			// if the music is playing or paused, stop it 
			mBackgroundMediaPlayer.stop();			
			 
			mBackgroundMediaPlayer.setLooping(isLoop);
			 
			try { 
				mBackgroundMediaPlayer.prepare();
				mBackgroundMediaPlayer.seekTo(0);
				mBackgroundMediaPlayer.start();
				 
				this.mIsPaused = false;
			} catch (Exception e){
				Log.e(TAG, "playBackgroundMusic: error state");
			}			 
		} 
	} 
Contextual code suggestions in your IDE  Get Codota for Java