The Android platform offers built-in encoding/decoding for a variety of common media types, so that can easily Integra Te audio, video, and images into your applications.
The Android platform has built-in encoding and decoding tools that enable developers to easily integrate audio videos and photos into their own applications.
Broadly divided into two items:
Using Android to play music and video, use MediaPlayer this class and related methods
Using Android to record audio and video, use Mediarecorder this class and related methods
Take a look: some common formats supported by Android:
From API
The supported audio formats are: WAVE,MP3,3GP, video format: MP4 3GP, image format: Jpg,gif,png, and BMP.
Audio and video playback:
Android lets you play audio and video from several types of data sources. You can play audio or video from media files stored in the application ' s resources (raw resources),
From standalone files on the filesystem, or from a data stream arriving over a network connection. To play audio or video from your application, use the MediaPlayer class.
The API recommends using MediaPlayer to play different types of resource files from different channels.
Familiarity: MediaPlayer
MediaPlayer class can used to control playback of audio/video files and streams. The object class of inheritance is under the Android.media package.
About the state diagram and Permissions section of MediaPlayer: View API.
Take a look at some of the common methods of MediaPlayer:
Default non-parametric construction method: MediaPlayer mp= new MediaPlayer ();
Three static methods:
These methods can be used to get the MediaPlayer resource object under different paths. For example: MediaPlayer MP = Mediaplayer.create (This,r.raw.cong);
Opened the audio resource for Cong under the res/raw/file. Call Mp.start () again to play the resource, paying attention to the exception capture .
The above four methods are used to obtain information about a resource: for example, to get the current position, to return to position in milliseconds, to return the length of the resource, the width and height of the video.
IsPlaying (), used to determine whether the playback, islooping () to determine whether to loop playback, the return value is a Boolean.
Android Audio and video