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创建视频播放
发表评论