Code example for VideoView

Methods: isPlayingsetMediaControllersetVideoPathstartstopPlayback

0
		this.layoutVideo = (LinearLayout) v.findViewById(R.id.layoutVideo);
		return v;
	}// onCreateView 
 
	public void stopPlayback() { 
		videoView.stopPlayback();
	}// stopPlayback 
 
	public void hide() { 
		layoutVideo.setVisibility(View.GONE);
	} // hide 
 
	public void update(ContentUnit content_unit) {
		if (this.contentUnit != null) {
			if (this.contentUnit.getParent() == null
					&& content_unit.getParent() != null) {
				this.stopPlayback();
			} else if (this.contentUnit.getAncestors() != null
					&& content_unit.getParent() == null) {
				this.stopPlayback();
			} else if (this.contentUnit.getParent() == null
					&& content_unit.getParent() == null) {
				// do nothing 
			} else if (this.contentUnit.getParent().equals(
					content_unit.getParent())) {
				// do nothing 
			} else { 
				this.stopPlayback();
			} 
		} 
		this.contentUnit = content_unit;
		if (this.contentUnit.hasMovie()) {
			// this.layoutVideo.bringToFront(); 
			this.layoutVideo.setBackgroundColor(Color.WHITE);
			if (!this.videoView.isPlaying()) {
				this.videoView.setVideoPath(content_unit.getMovieFile()
						.getAbsolutePath()); 
				this.videoView.setMediaController(new MediaController(getActivity()));
				this.videoView.start();
			} 
			this.layoutVideo.setVisibility(View.VISIBLE);
		} else { 
			this.layoutVideo.setVisibility(View.GONE);
		}// if contentunit has a movie