美文网首页
简单videoview播放视屏(videoview只支持mp4,

简单videoview播放视屏(videoview只支持mp4,

作者: phi3 | 来源:发表于2017-09-14 16:05 被阅读0次

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,

      本文链接:https://www.haomeiwen.com/subject/xqpdsxtx.html