Reputation: 1976
The YouTube API v3 allows you to request information about a video, such as its title, description, etc.
Is there a way to determine whether the video supports HD resolution?
A workaround could be to look for a maxres
thumbnail:
var checkURL = "https://www.googleapis.com/youtube/v3/videos?key=XYZ&part=snippet&fields=items(snippet(thumbnails))&id=" + uid;
$.getJSON(checkURL, function(data) {
if (data.items.length > 0) {
/* Verify this video is HD */
if (data.items[0].snippet.thumbnails.maxres == undefined) {
alert("This video does not support HD")
}
}
});
but is there a better approach?
Upvotes: 0
Views: 142
Reputation: 7122
You can check if a video supports HD by reading contentDetails.definition
in a video
resource:
string
Indicates whether the video is available in high definition (HD) or only in standard definition.
Valid values for this property are:
hd
,sd
Upvotes: 3