In my Android app, I have an embedded video on YouTube.
I get the Youtube video id from the source URL as follows:
private String extractYoutubeId(String url) { String video_id = ""; if (url != null && url.trim().length() > 0 && url.startsWith("http")) { String expression = "^.*((youtu.be" + "\\/)" + "|(v\\/)|(\\/u\\/w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*"; CharSequence input = url; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(input); if (matcher.matches()) { String groupIndex1 = matcher.group(7); if (groupIndex1 != null && groupIndex1.length() == 11) video_id = groupIndex1; } } return video_id; }
This is great for the original URL: http://www.youtube.com/watch?v=A7ry4cx6HfY
When I do this, the video loads and plays perfectly, but the quality is very poor. (240p or worse, I think)
So, from googling, I know that you just need to add a parameter like &vq=large or &vq=hd1080 to get 480p / 1080p.
But when I use this URL http://www.youtube.com/watch?v=A7ry4cx6HfY&vq=hd1080 , this parameter is ignored, and the quality is still bad.
How can I get a video in the best quality? Of course, assuming the video is available for this quality. Why is my parameter ignored?
source share