如何测试YouTube视频是否支持高清分辨率?
How to test whether a YouTube video supports HD resolution?
YouTube API v3 允许您request information关于视频,例如它的标题、描述等
有没有办法判断视频是否支持高清分辨率?
A workaround 可能是寻找 maxres
缩略图:
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")
}
}
});
但是有更好的方法吗?
您可以通过阅读 video
资源中的 contentDetails.definition
来检查视频是否支持高清:
string
Indicates whether the video is available in high definition (HD) or only in standard definition.
Valid values for this property are: hd
, sd
YouTube API v3 允许您request information关于视频,例如它的标题、描述等
有没有办法判断视频是否支持高清分辨率?
A workaround 可能是寻找 maxres
缩略图:
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")
}
}
});
但是有更好的方法吗?
您可以通过阅读 video
资源中的 contentDetails.definition
来检查视频是否支持高清:
string
Indicates whether the video is available in high definition (HD) or only in standard definition.
Valid values for this property are:
hd
,sd