In addition to using MediaPlayer to play videos, Android also provides a VideoView to play videos more conveniently. VideoView is a subclass of View. It can be used in all places that support View, including its definition in the AndroidManifest. xml file:
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "vertical"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
>
<VideoView
Android: id = "@ + id/surface_view"
Android: layout_width = "320px"
Android: layout_height = "240px"
/>
</LinearLayout>
VideoView can play files from resources, networks, or Content providers. It can also be an image adaptive screen, and provides scaling and other functions. You can also provide "forward", "back", "play", and "pause" buttons on the screen.
[Java]
Path = "/sd card/dcim/camera/test.3gp ";
// Path = "http://www.imobilebbs.com/download/android/boy.3gp ";
MVideoView. setVideoPath (path );
MVideoView. setMediaController (new MediaController (this ));
MVideoView. requestFocus ();
Path = "/sd card/dcim/camera/test.3gp ";
// Path = "http://www.imobilebbs.com/download/android/boy.3gp ";
MVideoView. setVideoPath (path );
MVideoView. setMediaController (new MediaController (this ));
MVideoView. requestFocus ();
Author: mapdigit