我正在尝试从urL播放Videoview中的视频,但它显示错误"无法播放此视频" ...这是我的代码和xml文件。我尝试了下面列出的各种网址
public class MainActivity extends Activity {
private static final String MOVIE_URL="https://www.youtube.com/watch?v=fv_pIbhKdzY";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView vid=(VideoView)findViewById(R.id.videoView1);
Uri video=Uri.parse(MOVIE_URL);
vid.setMediaController(new MediaController(this));
vid.setVideoURI(video);
vid.start();
vid.requestFocus();
}
}
xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.vid.MainActivity" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
我试过这些Uri
http://s1133.photobucket.com/albums/m590/Anniebabycupcakez/?action=view& current=1376992942447_242.mp4
https://www.youtube.com/watch?v=fv_pIbhKdzY
https://www.youtube.com/watch?v=OZJalBmtGnQ
答案 0 :(得分:0)
试试这个
VideoView mVideoView = (VideoView) findViewById(R.id.videoView1);
mVideoView.setMediaController(new MediaController(this));
String viewSource ="https://www.youtube.com/watch?v=fv_pIbhKdzY";
mVideoView.setVideoURI(Uri.parse(viewSource));
答案 1 :(得分:0)