Preface
This chapter is about android. widget. MediaController. The version is Android 2.3 r1 and translated from "Tang Ming". Thank you again "Tang Ming "! I look forward to your participation in Android Chinese API translation, contact me over140@gmail.com.
Statement
You are welcome to repost, but please keep the original source of the article :)
Blog Garden: http://www.cnblogs.com/
Android Chinese translation group: http://goo.gl/6vJQl
Body
I. St
As follows:(PS is supposed to give everyone to wear GIF dynamic diagram, but too big, unable to upload)Feature implementation: Pause, play, fast forward, rewind, fullscreen, exit fullscreen, etc. basic functionsRealization of the idea:Place a surfaceview in the main layout, place a mediaplayer in the Surfaceview, and customize a mediacontroller underneath it, but it's not called Mediacontroller, Using Pupup
The media component of the Flash MX 2004 is really good, when you use it you may find that the Mediadisplay component can play only one mp3, and if you want to play a song and then play another song, you can't. Today to introduce you how to use Mediacontroller and mediadisplay components to achieve a number of MP3 network.
The player interface is shown in figure:
Ideas are as follows:
The song list is recorded with an external XML file for easy modif
The media component of the Flash MX 2004 is really good, when you use it you may find that the Mediadisplay component can play only one mp3, and if you want to play a song and then play another song, you can't. Today to introduce you how to use Mediacontroller and mediadisplay components to achieve a number of MP3 network.The player interface is shown in figure:Ideas are as follows:The song list is recorded with an external XML file for easy modificat
. IsPlaying (): Whether the current videoview is playing video. void Pause (): pauses void seekto (int msec): plays from the first few milliseconds. void Resume (): Replay. void Setvideopath (String path): Sets the Videoview playback video source as a file path. void Setvideouri (URI uri): Sets the Videoview playback video source as a URI, either a network URI or a local URI. void Start (): Starts playback. void Stopplayback (): Stops playback. Setmediacontroller (
The media component of the Flash MX 2004 is really good, when you use it you may find that the Mediadisplay component can play only one mp3, and if you want to play a song and then play another song, you can't. Today to introduce you how to use Mediacontroller and mediadisplay components to achieve a number of MP3 network.
The player interface is shown in figure:
Ideas are as follows:
The song list is recorded with an external XML file for easy modif
1. Concepts and extensionsVideoView is a media playback display and Control control provided by the android system. Its structure is as follows:Prototype: VideoView extends SurfaceView implements MediaController. MediaPlayerControlClass Structure:Java. lang. ObjectUsing android. view. ViewUsing android. view. SurfaceViewUsing android. widget. VideoViewBased on the VideoView prototype, we can see that if you build a more complex and distinctive Video V
Android provides the Videoview component, which works like ImageView, except that ImageView is used to display the picture, and Videoview is used to play the video.Use Videoview the steps to play the video are as follows:1) Define the Videoview component in the interface layout file, or create the Videoview component in the program.2) Call Videoview The following two methods to load the specified video.Setvideopath (String path): Loads the video represented by the path file.Setvideouri (Uri uri)
Method 1
Procedure:1. Create a New FLASH file and set the stage size to 300*260.2. Drag the components mediacontroller and mediadisplay to the stage and delete them from the stage. The purpose is to load these two components into the database and prepare for loading the mediacontroller and mediadisplay components to the stage using the attachmovie () method.3. Create a new layer named function. Enter the
Video playback using VideoView in Android Development
Android provides the VideoView component, which is similar to ImageView, but ImageView is used to display images while VideoView is used to play videos.
To use VideoView to play a video, follow these steps:
1) define the VideoView component in the interface layout file or create a VideoView component in the program.
2) call the following two methods of VideoView to load the specified video.
SetVideoPath (String path): loads the video represen
To play video in Android apps, Android offers the Videoview component, It is a component that is located under the Android.widget package, which functions like ImageView, except that ImageView is used to display the image and Videoview to play the video.To play a video using Videoview, follow these steps:1. Define the Videoview component in the interface layout file, or create the Videoview component in the program.2, call Videoview the following two methods to load the specified video:Setvideop
in the in Android, we have three ways to play Video: 1, with its own player. Specifies that the action is action_view,data to Uri,type for its MIME type. 2, use Videoview to play. Use Videoview in the layout file to control it with Mediacontroller. 3, using MediaPlayer class and Surfaceview to achieve, this way is very flexible. 1, call its own player:
Uri uri = Uri.parse (Environment.getexternalstoragedirectory (). GetPath () + "/test_movie.m4v");
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. (M
);mVideoView.setVideoPath(path);
VideoViewcontrol the flow of video playback using the provided interface,//从头开始播放视频mVideoView.start();//暂停播放视频mVideoView.pause();//继续播放视频mVideoView.resume()//跳转到xxx毫秒处开始播放mVideoView.seekTo(xxx);
You can also VideoView add Control Panel- MediaController This panel integrates the play progress drag, pause, resume playback and other functions, but also can be automatically hidden or displayed. If VideoView there is a
Video Playback is more complex than audio playback. In addition to audio, you also need to consider a visual component. To solve this problem, Android provides a dedicated View Controller android. widget. videoview encapsulates the creation and initialization processes of mediaplayer. This widget can be used in any layout manager and provides many display options, including scaling and coloring. To implement the playback function, we need to create a videoview widget and set it to the content of
Video summary for VideoView development and video DevelopmentI. Summary of VideoView and Its Related Components
In Android, you can play a video in two ways. The first method is to use MediaPlayer and SurfaceView to play the video. MediaPlayer is used to control the playback, pause, and progress of the video, surfaceView is used to display the video content. The second method is to use VideoView for playback. This class actually inherits the SurfaceView class and implements
This article describes how to use VideoView to play a local video. It is relatively simple to use. The MediaController class is added in it to implement more video control functions.
Implementation:
Code;
Layout file:
With VideoView, VideoView is a view with the video playback function, which can be used directly in the layout.
MainActivity:
Package com. multimediademo11videoview; import android. app. activity; import android.net. uri;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.