回答
我發現這個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