Code example for VideoView

Methods: setMediaControllersetOnCompletionListenersetVideoPathsetVideoURIstart, requestFocus

1
	public Void playVideoOffline(Context context, String filePath,
			VideoView videoView) {
 
		Log.d(TAG, "Playing video offline");
 
		videoView.setVideoPath(filePath);
 
		MediaController mediaController = new MediaController(context);
		mediaController.setMediaPlayer(videoView);
 
		videoView.setMediaController(mediaController);
		videoView.requestFocus();
		videoView.start();
 
		videoView.setOnCompletionListener(new OnCompletionListener() {
 
			public void onCompletion(MediaPlayer arg0) {
				 
				arg0.release();
				// TODO RETURN TO LAST SCREEN 
			} 
		}); 
 
		return null; 
	} 
 
	/** 
	 * Play a video streaming 
	 *  
	 * @param context 
	 * @param url 
	 * @param videoView 
	 *  
	 * @return Void 
	 */ 
	public Void playVideoStream(Context context, String url, VideoView videoView) {
 
		Log.d(TAG, "Playing video stream");
 
		MediaController mediaController = new MediaController(context);
		mediaController.setAnchorView(videoView);
 
		Uri video = Uri.parse(url);
		videoView.setMediaController(mediaController);
		videoView.setVideoURI(video);
		videoView.start();
 
		videoView.setOnCompletionListener(new OnCompletionListener() {
 
			public void onCompletion(MediaPlayer arg0) {
				// TODO RETURN TO LAST SCREEN 
 
			}