android Vitamio(维他命)入门

Vitamio 官网:https://www.vitamio.org/

sdk下载地址:https://www.vitamio.org/Download/

下载后解压里面是这样的


然后eclipse导入那个5.0.1的工程,导入时有两个工程一个依赖工程一个demo

然后再清单文件加入权限

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

然后就贴代码了:

public class MainActivity extends Activity {
private VideoView videoView;
private String [] video ={
"http://dlqncdn.miaopai.com/stream/MVaux41A4lkuWloBbGUGaQ__.mp4",
        "http://movie.ks.js.cn/flv/other/2014/06/20-2.flv",
        "http://movie.ks.js.cn/flv/other/1_0.mp4"
        };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Vitamio.isInitialized(this);
initView();
}
private void initView() {
videoView=(VideoView) findViewById(R.id.videoView);
videoPlay();
}
private void videoPlay() {
String path = "";
path=video[new Random().nextInt(video.length)];
//播放文件路径
videoView.setVideoPath(path);
videoView.setMediaController(new MediaController(this));
videoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);
videoView.requestFocus();
//准备播放器
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(io.vov.vitamio.MediaPlayer mp) {
mp.setPlaybackSpeed(1.0f);//播放速度正常1.0
}
});
//播放完的监听
videoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(io.vov.vitamio.MediaPlayer mp) {
mp.seekTo(0);
mp.start();
}
});
}
}


    



阅读更多
文章标签: android Vitamio
个人分类: android 第三方库
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭