Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Youtube thumb url from video Id
/**
*
* Created by matheusjardimb on 14/11/2014.
*/
public class YoutubeUtils {
private static final String BASE_URL = "http://img.youtube.com/vi/";
private static final String EXT = ".jpg";
public static String getThumbUrl(String videoId) {
return getThumbUrl(videoId, VideoSize.DEFAULT);
}
public static String getThumbUrl(String videoId, VideoSize videoSize) {
return BASE_URL + videoId + videoSize.toString() + EXT;
}
@SuppressWarnings("SpellCheckingInspection")
public enum VideoSize {
DEFAULT("/default"),
HQ("/hqdefault"),
MQ("/mqdefault"),
SD("/sddefault"),
MAXRES("/maxresdefault");
private String size;
VideoSize(String size) {
this.size = size;
}
@Override
public String toString() {
return size;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.