Android Audio and video

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.