Code example for MediaPlayer: Playing audio and video

Methods: getVideoHeightgetVideoWidthstart

0
 
			alertDialogBuilder.create();
			alertDialogBuilder.show();
			return; 
		} else { 
			mediaPlayer.start();			
			setMetaData(); 
		} 
	} 
	 
	 
	/** 
	 *  
	 */ 
	protected void setMetaData() { 
		new WatchedVideoAsyncTask().execute(videoId);
		boolean showOSD = preferences.getBoolean("internal_player_osd", true);
		if (showOSD) {
			mediaController.show(SerenitySurfaceViewVideoActivity.CONTROLLER_DELAY);
		} 
		if (progressReportingHandler != null) {
			progressReportingHandler.postDelayed(progressRunnable, 5000);
		} 
	} 
	 
	/** 
	 * Setup the aspect ratio for the SurfaceView 
	 *  
	 * @return 
	 */ 
	protected android.view.ViewGroup.LayoutParams setupAspectRatio(SurfaceView surfaceView, String plexAspectRatio) {
		RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) surfaceView
				.getLayoutParams();
 
		SharedPreferences prefs = PreferenceManager
				.getDefaultSharedPreferences(context);
		boolean preferPlexAspectRatio = prefs.getBoolean("plex_aspect_ratio",
				false); 
 
		int surfaceViewHeight = surfaceView.getHeight();
		int surfaceViewWidth = surfaceView.getWidth();
 
		float videoWidth = mediaPlayer.getVideoWidth();
		float videoHeight = mediaPlayer.getVideoHeight();
 
		float ratioWidth = surfaceViewWidth / videoWidth;
		float ratioHeight = surfaceViewHeight / videoHeight;
		float aspectRatio = videoWidth / videoHeight;