无法使用RTSP流在VideoView中播放YouTube视频

时间:2011-08-09 12:41:25

标签: android streaming rtsp android-videoview

我正在编写一个使用VideoView播放YouTube视频的应用。

这是我的代码:

VideoView videoView = (VideoView)findViewById(R.id.video_view);
videoView.setVideoURI(Uri.parse(filePath));
videoView.setMediaController(new MediaController(this));
videoView.requestFocus();
videoView.start();

代码适用于此网址:“http://commonsware.com/misc/test2.3gp”

但不是这个(来自YouTube,通过API): “RTSP://v4.cache7.c.youtube.com/CjsLENy73wIaMgl4q-dkJkOfrRMYDSANFEIXZ29vZ2xlLW1vdW50YWludmlldy0wLjFIBlIGdmlkZW9zDA==/0/0/0/video.3gp”

错误日志如下。请注意:我想控制播放,所以我不是在寻找一个涉及使用意图来启动独立的YouTube播放器的解决方案。当我这样做时,YouTube视频会播放,但这不是我需要做的。

真的很感激任何帮助。

08-09 08:01:34.923: INFO/AwesomePlayer(34): setDataSource_l('rtsp://v4.cache7.c.youtube.com/CjsLENy73wIaMgl4q-dkJkOfrRMYDSANFEIXZ29vZ2xlLW1vdW50YWludmlldy0wLjFIBlIGdmlkZW9zDA==/0/0/0/video.3gp')
08-09 08:01:35.003: INFO/MyHandler(34): connection request completed with result 0 (Unknown error: 0)
08-09 08:01:35.053: INFO/ARTSPConnection(34): status: RTSP/1.0 200 OK
08-09 08:01:35.083: INFO/MyHandler(34): DESCRIBE completed with result 0 (Unknown error: 0)
08-09 08:01:35.103: INFO/ASessionDescription(34): v=0
08-09 08:01:35.103: INFO/ASessionDescription(34): o=GoogleStreamer 1080479110 1215825987 IN IP4 74.125.214.211
08-09 08:01:35.103: INFO/ASessionDescription(34): s=Video
08-09 08:01:35.103: INFO/ASessionDescription(34): c=IN IP4 0.0.0.0
08-09 08:01:35.112: INFO/ASessionDescription(34): b=AS:73
08-09 08:01:35.112: INFO/ASessionDescription(34): t=0 0
08-09 08:01:35.112: INFO/ASessionDescription(34): a=control:*
08-09 08:01:35.112: INFO/ASessionDescription(34): a=range:npt=0-21.333000
08-09 08:01:35.112: INFO/ASessionDescription(34): m=video 0 RTP/AVP 98
08-09 08:01:35.112: INFO/ASessionDescription(34): b=AS:61
08-09 08:01:35.122: INFO/ASessionDescription(34): a=rtpmap:98 H263-2000/90000
08-09 08:01:35.122: INFO/ASessionDescription(34): a=control:trackID=0
08-09 08:01:35.122: INFO/ASessionDescription(34): a=cliprect:0,0,144,176
08-09 08:01:35.122: INFO/ASessionDescription(34): a=framesize:98 176-144
08-09 08:01:35.122: INFO/ASessionDescription(34): a=fmtp:98 profile=0;level=10
08-09 08:01:35.122: INFO/ASessionDescription(34): m=audio 0 RTP/AVP 99
08-09 08:01:35.143: INFO/ASessionDescription(34): b=AS:12
08-09 08:01:35.143: INFO/ASessionDescription(34): a=rtpmap:99 AMR/8000/1
08-09 08:01:35.143: INFO/ASessionDescription(34): a=control:trackID=1
08-09 08:01:35.143: INFO/ASessionDescription(34): a=fmtp:99 octet-align
08-09 08:01:35.212: INFO/ARTSPConnection(34): status: RTSP/1.0 200 OK
08-09 08:01:35.232: DEBUG/dalvikvm(567): GC_CONCURRENT freed 443K, 7% free 7156K/7687K, paused 5ms+4ms
08-09 08:01:35.242: INFO/MyHandler(34): SETUP(1) completed with result 0 (Unknown error: 0)
08-09 08:01:35.292: INFO/ARTSPConnection(34): status: RTSP/1.0 200 OK
08-09 08:01:35.312: INFO/MyHandler(34): SETUP(2) completed with result 0 (Unknown error: 0)
08-09 08:01:35.353: INFO/ARTSPConnection(34): status: RTSP/1.0 200 OK
08-09 08:01:35.382: INFO/MyHandler(34): PLAY completed with result 0 (Unknown error: 0)
08-09 08:01:45.383: WARN/MyHandler(34): Never received any data, switching transports.
08-09 08:01:45.424: INFO/ARTSPConnection(34): status: RTSP/1.0 200 OK
08-09 08:01:45.433: INFO/MyHandler(34): TEARDOWN completed with result 0 (Unknown error: 0)
08-09 08:01:45.538: INFO/MyHandler(34): connection request completed with result 0 (Unknown error: 0)
08-09 08:01:45.582: INFO/ARTSPConnection(34): status: RTSP/1.0 200 OK
08-09 08:01:45.612: INFO/MyHandler(34): DESCRIBE completed with result 0 (Unknown error: 0)
08-09 08:01:45.612: INFO/ASessionDescription(34): v=0
08-09 08:01:45.612: INFO/ASessionDescription(34): o=GoogleStreamer 845535255 1838195113 IN IP4 74.125.214.211
08-09 08:01:45.612: INFO/ASessionDescription(34): s=Video
08-09 08:01:45.612: INFO/ASessionDescription(34): c=IN IP4 0.0.0.0
08-09 08:01:45.612: INFO/ASessionDescription(34): b=AS:73
08-09 08:01:45.612: INFO/ASessionDescription(34): t=0 0
08-09 08:01:45.623: INFO/ASessionDescription(34): a=control:*
08-09 08:01:45.623: INFO/ASessionDescription(34): a=range:npt=0-21.333000
08-09 08:01:45.623: INFO/ASessionDescription(34): m=video 0 RTP/AVP 98
08-09 08:01:45.623: INFO/ASessionDescription(34): b=AS:61
08-09 08:01:45.623: INFO/ASessionDescription(34): a=rtpmap:98 H263-2000/90000
08-09 08:01:45.623: INFO/ASessionDescription(34): a=control:trackID=0
08-09 08:01:45.633: INFO/ASessionDescription(34): a=cliprect:0,0,144,176
08-09 08:01:45.633: INFO/ASessionDescription(34): a=framesize:98 176-144
08-09 08:01:45.633: INFO/ASessionDescription(34): a=fmtp:98 profile=0;level=10
08-09 08:01:45.633: INFO/ASessionDescription(34): m=audio 0 RTP/AVP 99
08-09 08:01:45.633: INFO/ASessionDescription(34): b=AS:12
08-09 08:01:45.633: INFO/ASessionDescription(34): a=rtpmap:99 AMR/8000/1
08-09 08:01:45.643: INFO/ASessionDescription(34): a=control:trackID=1
08-09 08:01:45.643: INFO/ASessionDescription(34): a=fmtp:99 octet-align
08-09 08:01:45.673: INFO/ARTSPConnection(34): status: RTSP/1.0 461 Unsupported Transport
08-09 08:01:45.683: INFO/MyHandler(34): SETUP(1) completed with result 0 (Unknown error: 0)
08-09 08:01:45.713: INFO/ARTSPConnection(34): status: RTSP/1.0 461 Unsupported Transport
08-09 08:01:45.723: INFO/MyHandler(34): SETUP(2) completed with result 0 (Unknown error: 0)
08-09 08:01:45.733: INFO/AwesomePlayer(34): ARTSPController::connect returned -2147483648
08-09 08:01:45.733: ERROR/MediaPlayer(567): error (1, -2147483648)
08-09 08:01:45.733: ERROR/MediaPlayer(567): Error (1,-2147483648)
08-09 08:01:45.733: DEBUG/VideoView(567): Error: 1,-2147483648

2 个答案:

答案 0 :(得分:0)

我们有这个并发现这是一个防火墙问题。好像UDP被阻止了。 在另一篇帖子上看到其他人说他们通过移动数据连接为他们工作,但不是wifi。可能是同样的问题 - 无线防火墙设置。

答案 1 :(得分:0)

将Internet权限添加到清单文件

 <uses-permission android:name="android.permission.INTERNET" />

还请尝试这些URI:

rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov

http://www.wowza.com/_h264/BigBuckBunny_175k.mov