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

发布于 2024-11-28 22:31:33 字数 5643 浏览 0 评论 0 原文

我正在编写一个使用 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”,

但不适用于此网址(通过 API 来自 YouTube): “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

I'm writing an app that uses VideoView to play a video from YouTube.

Here's my code:

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

The code works with this url: "http://commonsware.com/misc/test2.3gp"

But not with this one (from YouTube via the API):
"rtsp://v4.cache7.c.youtube.com/CjsLENy73wIaMgl4q-dkJkOfrRMYDSANFEIXZ29vZ2xlLW1vdW50YWludmlldy0wLjFIBlIGdmlkZW9zDA==/0/0/0/video.3gp"

Error logs are below. Please note: I want to control the playback, so I'm not looking for a solution that involves using intents to start the standalone youtube player. When I do that, the YouTube video plays, but it's not what I need to do.

Really would appreciate any help with this.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦幻之岛 2024-12-05 22:31:33

我们遇到了这个问题,发现这是防火墙问题。看来 UDP 被阻止了。
在另一篇文章中看到其他人说这对他们来说适用于移动数据连接,但不适用于 wifi。可能有同样的问题 - wifi 防火墙设置。

We had this and discovered that it was a firewall issue. Seems like UDP is being blocked.
Saw somebody else on another post who said that it worked for them with a mobile data connection, but not wifi. Probably the same issue there - wifi firewall settings.

空袭的梦i 2024-12-05 22:31:33

将 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

add the Internet permission to the manifest file

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

and also please try these URIs:

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

http://www.wowza.com/_h264/BigBuckBunny_175k.mov
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文