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();
标签:mediacontroller,java,Random,vvVideos,video,new,Android,VideoView,LinearLayout 来源: https://www.cnblogs.com/javalinux/p/16200330.html