vitamio是和javaApi一样。开源框架,能够进行多种视频格式播放
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <io.vov.vitamio.widget.VideoView android:id="@+id/vv" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout>
package com.example.videoview; import io.vov.vitamio.LibsChecker; import io.vov.vitamio.widget.VideoView; import android.os.Bundle; import android.app.Activity; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //检测时候支持vitamio,并且在清单文件要配置activity // <activity android:name="io.vov.vitamio.activity.InitActivity"></activity> if(!LibsChecker.checkVitamioLibs(this)){ return; } VideoView vv = (VideoView) findViewById(R.id.vv); vv.setVideoPath("sdcard/mov_bbb.mp4"); vv.start(); } }
关联vitamio 右键点击要关联工程然后选择properties然后选择android,在选择Libiary里的add进行关联就可以了