Audio and video Instant Messaging-android video development

Source: Internet
Author: User

Mobile Internet with the popularization of the use of smartphones more and more widely, so-called mobile internet is to integrate mobile communications and the Internet, so that mobile devices (including mobile phones and netbooks, pad platform) can access the Internet resources and applications anytime and anywhere to obtain the appropriate information and processing.

Starting from 2011, the "Triple network integration" was formally included in the Twelve-Five plan by the State Council and began implementation. The State Council has made it clear that the integration of the three networks as an important means to improve the level of information technology, and highlight the importance of the three-network integration in the national strategic level development, but also for the three network integration in the 35 period of the development of a clear direction and objectives. In the same governance platform, the realization of audio, video, data transmission and management, to provide a variety of broadband applications and traditional telecommunications services, is a true broadband narrowband integration, wired and wireless integration, active passive integration, transmission and integration of integrated service network. Let a fiber solve the dream of watching TV, making phone calls and surfing the internet into reality. Now a network cable through the WiFi can connect all the communication equipment, mobile Internet and anytime and anywhere convenience, the future mobile internet will be the same as the traditional Internet, even there is a trend beyond!

According to this trend, the small part teaches you how to develop audio and video through the Android system

How to play one of the available media audio in your own application:

1. Put the file in your project's Res/raw folder, in this folder, the Eclipse plugin will find it, at the same time, will be this resource with your R

associated with the class;

2. Create a MediaPlayer and use mediaplayer.create to correlate with the resource, and then use the start () method in the instance.

For example: MediaPlayer mp=mediaplayer.create (context,r.raw.sound_file_1);

Mp.start ();

If you want to stop playback, use the Stop () method. If you want to replay this media later, you must use the start () method again before using the

The Reset () method and the Prepare () method manipulate the MediaPlayer object. (Create () call prepare () for the first time)

If you want to pause playback, you can use the pause () method. The Resume playback function can be implemented using the start () method where you paused.

Play a file

Here's how to play a file:

1, create a MediaPlayer instance with new;

2, call the Setdatasource () method, this method has a string parameter, this string type parameter contains you want to play the

The path to the file-the local file system or the URL;

3, after that, call the prepare () method first, then the start () method.

For example:

MediaPlayer mp=new MediaPlayer ();

Mp.setdatasource (Path_to_file);

Mp.prepare ();

Mp.start ();

One thing to note is that if you pass a URL-style file, the file must be downloadable, uninterrupted, and simply

How to record Media Audio resources:

1, use new to create an instance android.media.MediaRecorder;

2, create a android.content.ContentValues instance and set some standard properties, like Title,timestamp, the most important is mime_type;

3. Create a path to the file to be placed, which can be created by Android.content.ContentResolver in the content database to create a

and automatically signs a path to the file.

4. Use the Mediarecorder.setaudiosource () method to set up audio resources; This will most likely be used to MediaRecorder.AudioSource.MIC;

5, use the Mediarecorder.setoutputformat () method to set the output file format;

6, using the Mediarecorder.setaudioencoder () method to set the audio encoding;

7, finally, the audio recorded by prepare () and start (), Stop () and release () are called at the end of the call.

Recorder=new Mediarecorder ();

Contentvalues values=new contentvalues (3);

Values.put (Mediastore.mediacolumns.title,some_name_here);

Values.put (Mediastore.mediacolumns.timestamp,system.currenttimemillis ());

Values.put (Mediastore.mediacolumns.mime_type,recorder.getmimecontenttype ();

Contentresolver contentresolver=new contentresolver ();

Uri Base=mediastore.audio.internal_content_uri;

Uri Newuri=contentresolver.insert (base,values); Inserts a column of data into a table at the given URL

Function prototype: Final Uri insert (url,contentvalues values);

if (newuri==null) {

Exception handling is required here, and we cannot create a new content entry here.

}

String Path=contentresolver.getdatafilepath (Newuri);

You can use Setpreviewdisplay () to display a preview to fit the view

Recorder.setaudiosource (MediaRecorder.AudioSource.MIC);

Recorder.setoutputformat (MediaRecorder.OutputFormat.THREE_GPP);

Recorder.setaudioencoder (MediaRecorder.AudioEncoder.AMR_NB);

Recorder.setoutputfile (path);

Recorder.prepare ();

Recorder.start ();

To stop recording:

Recorder.stop ();

Recorder.release ();

In the process of recording audio resources, the Contentvalues class is used, and the class is explained below.

Contentvalues This class is used to store a series of values that require contentresolver to process.

The contentvalues (int size) constructor creates an empty series value with the given initial value.

Contentvalues (Contentvalues from) This constructor creates a value that is generated from the given contentvalues for replication.

This class has the following common methods:

void Clear () to remove all values

Boolean ContainsKey (String key) returns True if the object has a named value

int describecontents () describes value types

Object get (String key) Gets the value

void put (String Key,integer value) adds a value to the corresponding set

In the development of the small part of the development process of most of the content is borrowed from anychat this free development document for two times development. Anychat is available for download at many download URLs. The inside for personal research and demo is FREE! The most important is the Anychat SDK is a set of multimedia instant Messaging Platform library, the vast majority of the need to use audio and video interaction system can be developed using the Anychat SDK. and Anychat SDK cross-platform feature is one of its distinctive highlights, currently supports Windows, Unix, Linux (x86, ARM), Android, iOS platform, basic general user use of the development platform can be used, the most valuable is to support VC + + , Delphi, C #, vb.net, QT and other development languages, have to say is a developer learn from the Magic platform!

Different platform versions can be downloaded to the URL: www.anychat.cn

And there are technical forums, any questions can be consulted, a professional will answer: http://bbs.anychat.cn/forum.php

Video recording is one of the development of Android video, audio and video instant messaging, Voice tong communication, video surveillance, video traffic and other development are on the Android platform to achieve, the future of the cross-platform Android Market is more colorful-.

Audio and video Instant Messaging-android video development

Related Article

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.