Java教程

Android VideoView 使用java创建视频播放

本文主要是介绍Android VideoView 使用java创建视频播放,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
final LinearLayout llGroup = (LinearLayout) findViewById(R.id.ll_group_video);
final VideoView vvVideos = new VideoView(this);
Random rand = new Random();
vvVideos.setId(rand.nextInt(10000));
llGroup.addView(vvVideos);

MediaController mediacontroller = new MediaController(this);
Random rand1 = new Random();
mediacontroller.setId(rand1.nextInt(30000) + 20000);
mediacontroller.setPadding(0,0,0,100);
mediacontroller.setAnchorView(vvVideos);
vvVideos.setMediaController(mediacontroller);

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(500, 500);
vvVideos.setLayoutParams(lp);

Uri video = Uri.parse(videoPath);
vvVideos.setVideoURI(video);

vvVideos.requestFocus();
vvVideos.start();
这篇关于Android VideoView 使用java创建视频播放的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!