我们有一些视频网址,并通过链接预览显示。所以,为了看到我们这样做的视频,
setContentView(R.layout.videoview_main);
videoview = (VideoView) findViewById(R.id.VideoView);
pDialog = new ProgressDialog(VideoViewActivity.this);
pDialog.setTitle("Android Video Streaming Tutorial");
pDialog.setMessage("Buffering...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
try {
MediaController mediacontroller = new MediaController(
VideoViewActivity.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
Uri video = Uri.parse(VideoURL);
videoview.setMediaController(mediacontroller);
videoview.setVideoPath("https://www.yyy.com/watch?v=werwsdf");
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
videoview.requestFocus();
videoview.setOnPreparedListener(new OnPreparedListener() {
// Close the progress bar and play the video
public void onPrepared(MediaPlayer mp) {
pDialog.dismiss();
videoview.start();
}
});
如果url以.mp4结尾,它可以工作,如果没有,它就不会工作。此外,如果我把youtube url它不支持。 因此在listview本身的android小部件的视频视图中是否有任何api可以播放。