Build 1.0_r1(from source)

android.widget
Class VideoView

java.lang.Object
  extended by android.view.View
      extended by android.view.SurfaceView
          extended by android.widget.VideoView
All Implemented Interfaces:
Drawable.Callback, KeyEvent.Callback, MediaController.MediaPlayerControl

public class VideoView
extends SurfaceView
implements MediaController.MediaPlayerControl

Displays a video file. The VideoView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling and tinting.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
(package private)  MediaPlayer.OnPreparedListener mPreparedListener
           
(package private)  SurfaceHolder.Callback mSHCallback
           
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, LAST_STATE_SET, mBottom, mContext, mCurrentAnimation, MIDDLE_STATE_SET, mLayoutParams, mLocation, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FIRST_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
VideoView(Context context)
           
VideoView(Context context, AttributeSet attrs)
           
VideoView(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 int getBufferPercentage()
           
 int getCurrentPosition()
           
 int getDuration()
           
 boolean isPlaying()
           
 boolean onKeyDown(int keyCode, KeyEvent event)
          Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.
protected  void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
           Measure the view and its content to determine the measured width and the measured height.
 boolean onTouchEvent(MotionEvent ev)
          Implement this method to handle touch screen motion events.
 boolean onTrackballEvent(MotionEvent ev)
          Implement this method to handle trackball motion events.
 void pause()
           
 int resolveAdjustedSize(int desiredSize, int measureSpec)
           
 void seekTo(int msec)
           
 void setMediaController(MediaController controller)
           
 void setOnCompletionListener(MediaPlayer.OnCompletionListener l)
          Register a callback to be invoked when the end of a media file has been reached during playback.
 void setOnErrorListener(MediaPlayer.OnErrorListener l)
          Register a callback to be invoked when an error occurs during playback or setup.
 void setOnPreparedListener(MediaPlayer.OnPreparedListener l)
          Register a callback to be invoked when the media file is loaded and ready to go.
 void setVideoPath(String path)
           
 void setVideoURI(Uri uri)
           
 void start()
           
 void stopPlayback()
           
 
Methods inherited from class android.view.SurfaceView
dispatchDraw, draw, gatherTransparentRegion, getHolder, onAttachedToWindow, onDetachedFromWindow, onScrollChanged, onSizeChanged, onWindowVisibilityChanged
 
Methods inherited from class android.view.View
addFocusables, addTouchables, applyDrawableToTransparentRegion, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, clearFocus, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, debug, debug, debugIndent, destroyDrawingCache, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawableStateChanged, finalize, findFocus, findViewById, findViewTraversal, findViewWithTag, findViewWithTagTraversal, fitSystemWindows, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasFocus, hasFocusable, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onCreateContextMenu, onCreateDrawableState, onDraw, onFinishInflate, onFocusChanged, onKeyMultiple, onKeyShortcut, onKeyUp, onLayout, onRestoreInstanceState, onSaveInstanceState, onSetAlpha, onWindowFocusChanged, performClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setFrame, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPadding, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mPreparedListener

MediaPlayer.OnPreparedListener mPreparedListener

mSHCallback

SurfaceHolder.Callback mSHCallback
Constructor Detail

VideoView

public VideoView(Context context)

VideoView

public VideoView(Context context,
                 AttributeSet attrs)

VideoView

public VideoView(Context context,
                 AttributeSet attrs,
                 int defStyle)
Method Detail

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Description copied from class: View

Measure the view and its content to determine the measured width and the measured height. This method is invoked by View.measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call View.setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by View.measure(int, int). Calling the superclass' View.onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override View.onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (View.getSuggestedMinimumHeight() and View.getSuggestedMinimumWidth()).

Overrides:
onMeasure in class SurfaceView
Parameters:
widthMeasureSpec - horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec - vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
See Also:
View.getMeasuredWidth(), View.getMeasuredHeight(), View.setMeasuredDimension(int, int), View.getSuggestedMinimumHeight(), View.getSuggestedMinimumWidth(), View.MeasureSpec.getMode(int), View.MeasureSpec.getSize(int)

resolveAdjustedSize

public int resolveAdjustedSize(int desiredSize,
                               int measureSpec)

setVideoPath

public void setVideoPath(String path)

setVideoURI

public void setVideoURI(Uri uri)

stopPlayback

public void stopPlayback()

setMediaController

public void setMediaController(MediaController controller)

setOnPreparedListener

public void setOnPreparedListener(MediaPlayer.OnPreparedListener l)
Register a callback to be invoked when the media file is loaded and ready to go.

Parameters:
l - The callback that will be run

setOnCompletionListener

public void setOnCompletionListener(MediaPlayer.OnCompletionListener l)
Register a callback to be invoked when the end of a media file has been reached during playback.

Parameters:
l - The callback that will be run

setOnErrorListener

public void setOnErrorListener(MediaPlayer.OnErrorListener l)
Register a callback to be invoked when an error occurs during playback or setup. If no listener is specified, or if the listener returned false, VideoView will inform the user of any errors.

Parameters:
l - The callback that will be run

onTouchEvent

public boolean onTouchEvent(MotionEvent ev)
Description copied from class: View
Implement this method to handle touch screen motion events.

Overrides:
onTouchEvent in class View
Parameters:
ev - The motion event.
Returns:
True if the event was handled, false otherwise.

onTrackballEvent

public boolean onTrackballEvent(MotionEvent ev)
Description copied from class: View
Implement this method to handle trackball motion events. The relative movement of the trackball since the last event can be retrieve with MotionEvent.getX() and MotionEvent.getY(). These are normalized so that a movement of 1 corresponds to the user pressing one DPAD key (so they will often be fractional values, representing the more fine-grained movement information available from a trackball).

Overrides:
onTrackballEvent in class View
Parameters:
ev - The motion event.
Returns:
True if the event was handled, false otherwise.

onKeyDown

public boolean onKeyDown(int keyCode,
                         KeyEvent event)
Description copied from class: View
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.

Specified by:
onKeyDown in interface KeyEvent.Callback
Overrides:
onKeyDown in class View
Parameters:
keyCode - A key code that represents the button pressed, from KeyEvent.
event - The KeyEvent object that defines the button action.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

start

public void start()
Specified by:
start in interface MediaController.MediaPlayerControl

pause

public void pause()
Specified by:
pause in interface MediaController.MediaPlayerControl

getDuration

public int getDuration()
Specified by:
getDuration in interface MediaController.MediaPlayerControl

getCurrentPosition

public int getCurrentPosition()
Specified by:
getCurrentPosition in interface MediaController.MediaPlayerControl

seekTo

public void seekTo(int msec)
Specified by:
seekTo in interface MediaController.MediaPlayerControl

isPlaying

public boolean isPlaying()
Specified by:
isPlaying in interface MediaController.MediaPlayerControl

getBufferPercentage

public int getBufferPercentage()
Specified by:
getBufferPercentage in interface MediaController.MediaPlayerControl

Build 1.0_r1(from source)

Please submit a feedback, bug or feature