我正在通过YouTube API访问视频链接:
JSONObject(videoString).getJSONObject("entry")
.getJSONObject("media$group").getJSONArray("media$content")
.getJSONObject(0).getString("url");
这给了我一个视频的链接,例如:
rtsp://v7.cache5.c.youtube.com/CiILENy73wIaGQlXg0iXvlQ9SBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
然后我尝试播放视频:
mVideoView.setVideoURI(result);
final MediaController mediaController = new MediaController(mActivity);
mVideoView.setMediaController(mediaController);
mVideoView.requestFocus();
mVideoView.start();
这在我运行ICS的平板电脑上工作正常,但似乎无法在GoogleTV上运行,在这种情况下我是否需要专门为GTV做些什么?
Logcat输出:
04-30 14:03:41.212: D/MediaPlayer(1132): Couldn't open file on client side, trying server side
04-30 14:03:41.308: D/dalvikvm(1132): GC_CONCURRENT freed 862K, 13% free 8303K/9479K, paused 0ms+2ms
04-30 14:03:51.920: E/MediaPlayer(1132): error (1, -2147483648)
04-30 14:03:51.920: E/MediaPlayer(1132): Error (1,-2147483648)
04-30 14:03:51.920: D/VideoView(1132): Error: 1,-2147483648
答案 0 :(得分:2)
我确认播放YouTube RTSP视频的VideoView适用于Google TV:
String vURL = "rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp";
mVideoView = (VideoView)this.findViewById(R.id.myvideoview);
mVideoView.setVideoURI(Uri.parse(vURL));
final MediaController mediaController = new MediaController(this);
mVideoView.setMediaController(mediaController);
mVideoView.requestFocus();
mVideoView.start();
我改变的只是解析不同的URL。然后在代码中尝试使用此工作网址。