我想在Android中通过programmatically..Still从你管下载视频现在我可以能够流这些你管videos.I在Internet..But搜索存在对me..Please没有完美的解决方案建议,可能的解决方案对于issue..Thanks
I want to download videos from you tube in android by programmatically..Still now i can able to stream these you tube videos.I searched in Internet..But there is no perfect solution for me..Please suggest that possible solutions for that issue..Thanks
检查this出。我用这个函数来提取从YouTube视频的直接下载链接(它返回一个链接数组)。所有你需要做的就是用这个来获取视频(而不是手机版!)的HTML code:
Check this out. I use this function to extract the direct download links from a youtube video (it returns an array with links). All you need to do is to get the html code of the video (not the mobile version!) using this:
// url = youtube link (e.g. http://www.youtube.com/watch?v=fJ9rUzIMcZQ)
public String DownloadText(String url) throws IOException{
String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1)";
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, userAgent);
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
String html = "";
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null)
{
str.append(line);
}
in.close();
html = str.toString();
return html;
}