package com.example.MyVideo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;
public class MyActivity extends Activity implements View.OnClickListener {
/**
* Called when the activity is first created.
*/
private Button btn;
private VideoView vv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn = (Button) findViewById(R.id.button);
btn.setOnClickListener(this);
vv = (VideoView) findViewById(R.id.videoView);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.button:
vv.setVideoURI(link);
break;
}
}
}
答案 0 :(得分:0)
如果您想直接在videoview中查看网址,请按以下方式使用:
VideoView mVideoView;
MediaController mcon;
String videourl="http://ww.abc.com/a";
mVideoView = (VideoView) findViewById(R.id.videoview);
mVideoView.setVideoURI(Uri.parse(videourl));
mVideoView.start();
如果您想从网址下载视频并保存在SD卡中,请更好地使用webview
和
WeViewClient
处理网址。参见本教程
http://androidtrainningcenter.blogspot.in/2013/11/download-file-videoaudiotext-through.html