1. MediaPlayer is used for audio and video playback. To use MediaPlayer for video/audio playback, follow these steps:
A. Generate a MediaPlayer object. Use different generation methods based on the playback file (refer to MediaPlayer API );
B. After obtaining the MediaPlayer object, call different methods based on your actual needs, such as start (), storp (), pause (), and release.
Note: When you do not need to play the video, release the playback file connected to the MediaPlayer object. (MediaPlayer objects are generally used for audio playback)
2. Video Playback is mainly implemented through the VideoView class and MediaController class. The implementation steps are as follows:
A. Generate a VideoView object, which can be implemented through an xml file or java code.
B. Create a video playback file for the generated VideoView object: VideoView. setVideoPath (String path);. Or VideoView. setVideoURI (Uri uri );
C. Generate a MediaController object, which can be implemented through an xml file or java code.
D. Associate the VideoView object with the MediaController object:
VideoView. setMediaController (MediaController mc );
MediaController. setMediaPlayer (VideoView vv );
MediaPlayer object operations are as follows: (In my Android album, the name is mediaplayer_state_di#image ).
From tianshijianbing1989