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



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

下面是我的代码:

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

代码与以下url一起工作:"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

我们发现这是一个防火墙问题。似乎UDP被阻止了。在另一个帖子上看到有人说,它可以在移动数据连接的情况下工作,但不是wifi。可能是同样的问题- wifi防火墙设置。

将Internet权限添加到manifest文件

 <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

最新更新