A brief introduction to integrating the Vitamio Android SDK

Source: Internet
Author: User

1. Download the latest Vitamiobundle stability, here is the most recent version of the 4.2.2.


2. After decompression, import Vitamio Library project (i.e. Vitamio) and demo project (i.e. vitamio--sample) to Eclipse, detailed steps such as.


Step: Import the project by using Android---Existing android Code into workspace file, import, and then modify the corresponding project name (or you can not modify it).


3. If the error is shown in the following illustration, the Vitamio Library project needs to be compiled using SDK API 17 (i.e. Android 4.2.2) and then imported by using the Android SDK Manager to download the appropriate version.

4. To introduce the Vitamio library in your new project, follow these steps:

1) Refer to the above steps to import the Vitamio library project (i.e. Vitamio) to eclipse.

2) Vitamio Library project as the Android library to introduce its own new use can be,


3) Load the decoder's lib in the OnCreate method of the activity that needs to play the video:

    Public void onCreate (Bundle icicle) {      super.oncreate (icicle);       if (! Libschecker.checkvitamiolibs (this))      return;        // other code ...      }

4) Declare initactivity in Androidmanifest.xml:

<Activity  Android:name="io.vov.vitamio.activity.InitActivity"android:configchanges="orientation|screensize|smallestscreensize|keyboard|keyboardhidden|navigation"Android:launchmode="Singletop"Android:theme="@android: Style/theme.notitlebar"Android:windowsoftinputmode="Statealwayshidden"/>

5) Start using the Vitamio API.

The

5.API uses

Vitamio APIs are very similar to Android native APIs, primarily for use by MediaPlayer and Videoview.

    1) MediaPlayer main API, for detailed usage see test demo:

Add Surfaceview to the layout file, and the video appears on Surfaceview.

  <surfaceview                    android:id="@+id/surface"                    android:layout_width ="wrap_content"                    android:layout_height="wrap_ Content"                    android:layout_gravity="center" > </SurfaceView>

The API in Java code uses:

 //Get SurfaceviewMpreview =(Surfaceview) Findviewbyid (r.id.surface); //get Surfaceview's SurfaceholderHolder =Mpreview.getholder (); Holder.addcallback ( This); //Create a MediaPlayer and set the listenerMmediaplayer =NewMediaPlayer ( This); //Set Resource PathMmediaplayer.setdatasource (path); //Set SurfaceholderMmediaplayer.setdisplay (holder);        Mmediaplayer.prepareasync (); Mmediaplayer.setonbufferingupdatelistener ( This); Mmediaplayer.setoncompletionlistener ( This); Mmediaplayer.setonpreparedlistener ( This); Mmediaplayer.setonvideosizechangedlistener ( This); Setvolumecontrolstream (audiomanager.stream_music);

2) Videoview main API use, detailed usage please see Test demo:

Add Videoview to the layout file:

<Io.vov.vitamio.widget.VideoView Android:id="@+id/surface_view"Android:layout_width="wrap_content"Android:layout_height="wrap_content"/>Android:text="@string/openvideo1"Android:onclick="Openvideo"/>

API calls to Java code:

//loading the decoding library        if(! Libschecker.checkvitamiolibs ( This))        return; Mvideoview=(Videoview) Findviewbyid (R.id.surface_view); //set the video path for VideoviewMvideoview.setvideopath (path); //set whether there is a playback control barMvideoview.setmediacontroller (NewMediacontroller ( This));                  Mvideoview.requestfocus (); Mvideoview.setonpreparedlistener (NewMediaplayer.onpreparedlistener () {@Override Public voidonprepared (MediaPlayer MediaPlayer) {//Set Playback speedMediaplayer.setplaybackspeed (1.0f);        }        }); }                  }

A brief introduction to integrating the Vitamio Android SDK

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.