sách gpt4 ăn đã đi

android - 如何在 Android 视频 View 中播放 Youtube 视频?

In lại Tác giả: IT Lão Cao 更新时间:2023-10-28 21:48:23 28 4
mua khóa gpt4 giày nike

我正在开发一个需要嵌入其中的 youtube 视频播放器的 android 应用程序。我成功地从 API 获得了 RTSP 视频 URL,但是当我试图在我的 android 视频 View 中加载这个 rtsp url 时,它显示“Can't play this video.”。之前我用这种方法开发了一个类似的应用,当时运行良好,但现在也加载失败了。

我确定,我从 API 获得了正确的 RTSP 网址。 rtsp://v6.cache6.c.youtube.com/CiULENy73wIaHALV9VII3c64lRMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp

这是我的 Activity 代码:

    mVideoURL = getIntent().getStringExtra("EXT_URL");
Log.i("VIDEO URL", " " + mVideoURL);

MediaController mc = new MediaController(this);
mVideoStreamView = (VideoView) findViewById(R.id.vidPlayer);

mVideoStreamView.setVideoURI(Uri.parse(mVideoURL));
mVideoStreamView.setMediaController(mc);
mVideoStreamView.requestFocus();
mVideoStreamView.start();

biên tập从 logcat 中找到了一些额外的信息:

ARTSPConnection(6607): status: RTSP/1.0 200 OK
ASessionDescription(6607): v=0
ASessionDescription(6607): o=GoogleStreamer 378992432 328144046 IN IP4 74.125.213.182
ASessionDescription(6607): s=Video
ASessionDescription(6607): c=IN IP4 0.0.0.0
ASessionDescription(6607): b=AS:29
ASessionDescription(6607): t=0 0
ASessionDescription(6607): a=control:*
ASessionDescription(6607): a=range:npt=0-1703.000000
ASessionDescription(6607): m=video 0 RTP/AVP 98
ASessionDescription(6607): b=AS:17
ASessionDescription(6607): a=rtpmap:98 H263-2000/90000
ASessionDescription(6607): a=control:trackID=0
ASessionDescription(6607): a=cliprect:0,0,144,176
ASessionDescription(6607): a=framesize:98 176-144
ASessionDescription(6607): a=fmtp:98 profile=0;level=10
ASessionDescription(6607): m=audio 0 RTP/AVP 99
ASessionDescription(6607): b=AS:12
ASessionDescription(6607): a=rtpmap:99 AMR/8000/1
ASessionDescription(6607): a=control:trackID=1
ASessionDescription(6607): a=fmtp:99 octet-align
ARTSPConnection(6607): status: RTSP/1.0 200 OK
ARTSPConnection(6607): status: RTSP/1.0 200 OK
ARTSPConnection(6607): status: RTSP/1.0 200 OK
ARTSPConnection(6607): status: RTSP/1.0 200 OK
ARTSPConnection(6607): status: RTSP/1.0 200 OK
ASessionDescription(6607): v=0
ASessionDescription(6607): o=GoogleStreamer 1299458498 503248054 IN IP4 74.125.213.182
ASessionDescription(6607): s=Video
ASessionDescription(6607): c=IN IP4 0.0.0.0
ASessionDescription(6607): b=AS:29
ASessionDescription(6607): t=0 0
ASessionDescription(6607): a=control:*
ASessionDescription(6607): a=range:npt=0-1703.000000
ASessionDescription(6607): m=video 0 RTP/AVP 98
ASessionDescription(6607): b=AS:17
ASessionDescription(6607): a=rtpmap:98 H263-2000/90000
ASessionDescription(6607): a=control:trackID=0
ASessionDescription(6607): a=cliprect:0,0,144,176
ASessionDescription(6607): a=framesize:98 176-144
ASessionDescription(6607): a=fmtp:98 profile=0;level=10
ASessionDescription(6607): m=audio 0 RTP/AVP 99
ASessionDescription(6607): b=AS:12
ASessionDescription(6607): a=rtpmap:99 AMR/8000/1
ASessionDescription(6607): a=control:trackID=1
ASessionDescription(6607): a=fmtp:99 octet-align
ARTSPConnection(6607): status: RTSP/1.0 461 Unsupported Transport
ARTSPConnection(6607): status: RTSP/1.0 461 Unsupported Transport

请建议我在 android 视频 View 中加载 youtube 视频的方法。

在此先感谢...

biên tập刚刚 checkin 另一台设备 HTC Desire (2.2)。代码运行良好。我想知道,Nexus (4.1) 会有什么问题?

câu trả lời hay nhất

由于我找不到在视频 View 中加载 rtsp URL 的任何方法(适用于所有设备和 android 版本),我通过另一种解决方法解决了我的问题。我使用 webview 将 youtube 播放器嵌入其中,这种方法在所有测试的设备中都运行良好。

Đây là mã của tôi:

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(PluginState.ON);
mWebView.loadUrl("http://www.youtube.com/embed/" + videoID + "?autoplay=1&vq=small");
mWebView.setWebChromeClient(new WebChromeClient());

非常感谢大家的帮助。

关于android - 如何在 Android 视频 View 中播放 Youtube 视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13814055/

28 4 0
Cựu chiến binh CNTT
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress