我想知道如何播放YouTube视频,我从YoutubeAPI数据v3获取了哪些网址:
https://www.youtube.com/watch?v=dpVUIwrNLoo&feature=youtube_gdata_player
我有以下代码执行此操作:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
VideoView videoView =(VideoView)findViewById(R.id.videoView);
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
String uri = getIntent().getStringExtra("url");
//Uri url = Uri.parse(uri);
videoView.setMediaController(mediaController);
videoView.setVideoPath(uri);
videoView.requestFocus();
videoView.start();
}
,布局xml就是这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView android:id="@+id/videoView"
android:layout_height="fill_parent"
android:layout_width="fill_parent"/>
</LinearLayout>
请尽快寻求帮助。