我正在开发一个android应用程序,它需要嵌入一个youtube视频播放器。我成功从API获取了RTSP视频网址,但在Android视频视图中尝试加载此rtsp网址时,它显示“Can't play this video.
”。以前我在这个方法中开发了一个类似的应用程序,当时它运行良好,但它现在也无法加载。如何在Android视频视图中播放Youtube视频?
我很确定,我从API获取正确的RTSP URL。 rtsp://v6.cache6.c.youtube.com/CiULENy73wIaHAlV9VII3c64lRMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp
这里是我的活动代码:
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();
编辑 发现从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的视频观看YouTube视频。
在此先感谢...
编辑 在其他设备刚才检查,的HTC Desire(2.2)。代码工作正常。 我想知道关于思考,Nexus(4.1)会出现什么问题?
检查了这一点:http://stackoverflow.com/questions/5162088/video-view-not-playing-youtube-video –
你应该使用youtube API的Android,它非常简单的方法 – vuhung3990
这是它将帮助的链接.. http://www.truiton.com/2013/08/android-videoview-example-with-youtube-playback/ –