流媒体的Youtube视频

流媒体的Youtube视频

本文介绍了流媒体的Youtube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个应用程序中使用流式播放YouTube视频。

I am writing an application to play youtube videos using streaming.

第一种方法:

我收到RTSP URL使用的GData API的视频。这里是code打RTSP URL。

I am getting the RTSP URL to the video using GData APIs.Here is the code to play the RTSP url.

   VideoView mVideoView = new VideoView(this);
   setContentView(mVideoView);
   mVideoView.setVideoURI(Uri.parse("rtsp://rtsp2.youtube.com/CiILENy73wIaGQkDwpjrUxOWQBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"));
   mVideoView.start();

但它抛出两个G1设备和仿真器上的错误(仿真器具有一定的防火墙的问题,因为每个邮件列表)这里是错误消息

But it throws error on both G1 device and emulator (Emulator has somefirewall problem as per mailing list)Here is the error message

ERROR / PlayerDriver(35):命令PLAYER_INIT完成,但有错误或信息PVMFFailure

ERROR/PlayerDriver(35): Command PLAYER_INIT completed with an error orinfo PVMFFailure

第二种方法:

一个黑客的方式来获得3GP文件的路径<一href="http://www.youtube.com/get_video?v=">http://www.youtube.com/get_video?v=&t=<>&<>..得到该文件的路径和之后,我可以打电话setVideoURI和它起着精细。但它是一个黑客的方法来达到要求。我已经检查了YouTube应用程序还,还没有破解的方式来播放YouTube的网址。(选中与logcat中)

A hack way to get the path of 3gp file fromhttp://www.youtube.com/get_video?v=&t=<>&<>..After getting the file path and I can call setVideoURI and it playsfine. But it is a hack way to achieve the requirement.I have checked the Youtube App also, it also does the hack way to playthe youtube url.(Checked with logcat)

我试图从VideoView到MediaPlayer的,但错误没有变化而变化。

I have tried changing from VideoView to MediaPlayer but no change in the error.

有一个干净的方式来做到这一点?

Is there a "Clean" way to do this?

请让我知道你的想法。

推荐答案

有时候Uri.parse返回空,因为着解析RTSP协议,而不是http协议。

Sometimes Uri.parse return "null" because cant parse an rtsp protocol instead of http protocol.

与登录看看它的logcat Uri.parse(RTSPURL)的ToString(),你会看到什么写。或仅使 Log.d(标签,Uri.parse); 键,同样会回归

Look it with an Log in logcat Uri.parse(rtspURL).toString() and you will see nothing written. or only make Log.d("tag", Uri.parse); and the same will be return.

尝试寻找另一种方式来解析(创建)一个开放的。

Try to find another way to parse (create) an Uri.

我会尝试与和运行:

String urlVideo = <your rtspURL>
VideoView video = (VideoView)findViewById(R.id.VideoView01);
Log.d(tag , urlVideo);
video.setVideoURI(Uri.parse(urlVideo));
MediaController mc = new MediaController(this);
video.setMediaController(mc);
video.requestFocus();
video.start();
mc.show();

这篇关于流媒体的Youtube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 17:13