简单videoview播放视屏(videoview只支持mp4,avi,3gp)

1、绑定好按键之后
videoView.setVideoURI(Uri.parse(+网络链接地址或手机文件视屏路径));
videoView.requestFocus();
videoView.start();//开始播放

2、全部代码 测试链接(http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4)

public class MainActivity extends AppCompatActivity {
private String ss=null;
private Button start;
private Handler handler;
private EditText editText;
private VideoView videoView;
private MediaController mediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
start = (Button) findViewById(R.id.send);
videoView = (VideoView) this.findViewById(R.id.video);
editText = (EditText) findViewById(R.id.edittext);
mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
mediaController.setMediaPlayer(videoView);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ss = editText.getText().toString();
playVideo(ss);
}
});
}
private void playVideo(String ss) {
videoView.setVideoURI(Uri.parse(ss));
videoView.requestFocus();
videoView.start();
}
}

你可能感兴趣的:(简单videoview播放视屏(videoview只支持mp4,avi,3gp))