回答
我发现这个blog entry,也许是它的一个起点。如果您继续使用<id>
链接,则会获得另一种格式,您应该在其中找到rtsp链接。编辑: 经过WarrenFaith发布的内容。 PROPS TO HIM
这就是你如何得到一个rtsp链接。
- 提出请求
- 解析数据为3GP内容
- 它也为您提供了评级和所有你可能需要的好东西。
希望帮助你们
Note:Working only android mobile(Not in Tablate)
private class YourAsyncTask extends AsyncTask<Void, Void, Void>`enter code here`
{
ProgressDialog progressDialog;
@Override
protected void onPreExecute()
{
super.onPreExecute();
progressDialog = ProgressDialog.show(AlertDetail.this, "", "Loading Video wait...", true);
}
@Override
protected Void doInBackground(Void... params)
{
try
{
String url = "http://www.youtube.com/watch?v=1FJHYqE0RDg";
videoUrl = getUrlVideoRTSP(url);
Log.e("Video url for playing=========>>>>>", videoUrl);
}
catch (Exception e)
{
Log.e("Login Soap Calling in Exception", e.toString());
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
progressDialog.dismiss();
/*
videoView.setVideoURI(Uri.parse("rtsp://v4.cache1.c.youtube.com/CiILENy73wIaGQk4RDShYkdS1BMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"));
videoView.setMediaController(new MediaController(AlertDetail.this));
videoView.requestFocus();
videoView.start();*/
videoView.setVideoURI(Uri.parse(videoUrl));
MediaController mc = new MediaController(AlertDetail.this);
videoView.setMediaController(mc);
videoView.requestFocus();
videoView.start();
mc.show();
}
}
public static String getUrlVideoRTSP(String urlYoutube)
{
try
{
String gdy = "http://gdata.youtube.com/feeds/api/videos/";
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
String id = extractYoutubeId(urlYoutube);
URL url = new URL(gdy + id);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
Document doc = documentBuilder.parse(connection.getInputStream());
Element el = doc.getDocumentElement();
NodeList list = el.getElementsByTagName("media:content");///media:content
String cursor = urlYoutube;
for (int i = 0; i < list.getLength(); i++)
{
Node node = list.item(i);
if (node != null)
{
NamedNodeMap nodeMap = node.getAttributes();
HashMap<String, String> maps = new HashMap<String, String>();
for (int j = 0; j < nodeMap.getLength(); j++)
{
Attr att = (Attr) nodeMap.item(j);
maps.put(att.getName(), att.getValue());
}
if (maps.containsKey("yt:format"))
{
String f = maps.get("yt:format");
if (maps.containsKey("url"))
{
cursor = maps.get("url");
}
if (f.equals("1"))
return cursor;
}
}
}
return cursor;
}
catch (Exception ex)
{
Log.e("Get Url Video RTSP Exception======>>", ex.toString());
}
return urlYoutube;
}
protected static String extractYoutubeId(String url) throws MalformedURLException
{
String id = null;
try
{
String query = new URL(url).getQuery();
if (query != null)
{
String[] param = query.split("&");
for (String row : param)
{
String[] param1 = row.split("=");
if (param1[0].equals("v"))
{
id = param1[1];
}
}
}
else
{
if (url.contains("embed"))
{
id = url.substring(url.lastIndexOf("/") + 1);
}
}
}
catch (Exception ex)
{
Log.e("Exception", ex.toString());
}
return id;
}
得到rtsp链接的短而简单的方式,应该是很容易移植到任何平台。
String video_id = "1FJHYqE0RDg";
String gdata = "http://gdata.youtube.com/feeds/api/videos/";
String youtube_response = Util.getUrlResponse(gdata+video_id); // just a simple HTTP GET
String rtsp_link = "rtsp:"+ StringUtils.split(StringUtils.split(youtube_response, "rtsp:")[1], ".3gp")[0] + ".3gp";
“Q-GLuydiMe4”ID不会通过这种方式打开。为什么? – 2014-02-24 11:22:27
Q-GLuydiMe4 id不会通过这种方式打开?你可以解释吗 ? – 2014-02-24 11:27:47
也许视频对其有其他限制。 – Ajibola 2014-02-24 18:29:33
没有一个程序如果u想要提取YOUTUBE RTSP链接,然后
GO TO www.youtube.com
选择ü希望其rtsp链接的视频... 。
转到该视频的网址.....
取从URL ID IE http://www.youtube.com/watch?v=6acRHWnfZAE ((所述由“=”的开始的ID和去高达结束... ...在上述情况下6acRHWnfZAE是视频的示例中的ID
现在打开http://gdata.youtube.com/feeds/api/videos/,然后在此URL上粘贴您的视频的ID ......
,打开的页面
现在搜索媒体:在页面 内容会有ATLEAST 3 属性 一会HTTP n中的另外两个将是RTSP (格式1 n 格式6); 按我的经验格式1仅用于视频,,,,ň格式6对于音频的N个视频都
来自youtube的回复:不再可用 – seoul 2015-06-28 18:19:30
- 1. 如何提取来自YouTube的RTSP链接饲料
- 2. 在MPMoviePlayerController播放Youtube视频或播放RTSP - 3GP链接
- 3. RTMP链接youtube
- 4. Youtube链接在WordPress
- 5. WebView上的YouTube链接未打开Youtube
- 6. TinyMCE删除youtube链接
- 7. 的YouTube链接和字幕
- 8. 解析youtube链接PHP
- 9. 不支持Youtube链接
- 10. 注册EXP YouTube的链接
- 11. FFMPEG流RTSP到RTMP(Youtube)添加徽标
- 12. youtube-dl如何生成直接链接?
- 13. 直接链接到YouTube评论功能
- 14. PHP的preg_replace Youtube链接到嵌入链接
- 15. 刮YouTube播放列表视频链接
- 16. Zend框架:YouTube视频链接验证
- 17. AS3检查,如果Youtube链接存在
- 18. 动态Youtube链接使用Colorbox打开
- 19. 每个YouTube视频两个链接
- 20. 超级链接播放YouTube视频
- 21. 从YouTube获取视频链接
- 22. Youtube视频供稿链接不工作
- 23. iphone - 如何从HTML提取youtube链接?
- 24. jQuery的 - Youtube链接到嵌入式
- 25. 在Twitter供稿中搜索YouTube链接?
- 26. ngFor YouTube与Angular2中的Domsanitizer链接
- 27. R闪亮 - 传递Youtube链接到iframe
- 28. YouTube从链接解析视频ID
- 29. 搜索朋友的共享YouTube链接
- 30. 提取的YouTube视频链接使用YouTube数据API
谢谢WarrenFaith:d – bluejamesbond 2012-01-03 17:46:58
“Q-GLuydiMe4” ID将无法通过这个开放方式 – 2014-02-24 11:16:53
Q-GLuydiMe4 id不会通过这种方式打开?为什么,你知道这个问题吗? – 2014-02-24 11:27:00