我试图通过我的 android 程序通过其 URL 播放 youtube 视频。我用过 setVideoURI(uri); 功能还可以设置 URI,正如 stackoverflow 中的其他 POST 所建议的那样。但我得到无法在客户端打开文件,尝试服务器端错误。你能弄清楚我的代码有什么问题吗?
但我可以通过注释代码播放任何本地视频。
这是我的android代码-
public class VideoActivity extends Activity {
//MediaPlayer song= new MediaPlayer();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
VideoView videoView = (VideoView)this.findViewById(R.id.VVSimpleVideo);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
//String _path = "mnt/sdcard/Movies/MyCameraApp/video6.mp4";
String _path = "http://www.youtube.com/watch?v=E43mgXNl0xc";
Uri uri=Uri.parse(_path);
videoView.setVideoURI(uri);
//videoView.setVideoPath(_path);
videoView.requestFocus();
videoView.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_video, menu);
return true;
}
}
这是日志错误-
10-11 04:51:23.480: D/MediaPlayer(4714): Couldn't open file on client side, trying server side
10-11 04:51:26.130: E/MediaPlayer(4714): error (1, -2147483648)
10-11 04:51:26.130: E/MediaPlayer(4714): Error (1,-2147483648)
10-11 04:51:26.130: D/VideoView(4714): Error: 1,-2147483648
10-11 04:51:26.190: D/dalvikvm(4714): GC_CONCURRENT freed 174K, 4% free 6785K/7047K, paused 4ms+3ms
提前致谢。