Code example for MediaPlayer: Playing audio and video

Methods: isPlayingsetLoopingsetVolumestart

0
			mp = MediaPlayer.create(context, music);
			if (mp == null) {
				Log.e(TAG, "musciplayer was not created successfully");
			} else { 
				try { 
					mp.setLooping(false);
//					pct = Preferences.getMusicVolume(context); 
				} catch (Exception e) {
					Log.e(TAG, e.getMessage(), e);
				} 
			} 
		} 
 
		if (!mp.isPlaying()) {
//			pct = Preferences.getMusicVolume(context); 
			Log.i(TAG, "Setting music at: " + pct);
			mp.setVolume(pct, pct);
			mp.start();
		} 
 
	} 
 
	public static void pause() { 
Experience pair programming with AI  Get Codota for Java