【发布时间】:2023-03-30 03:05:01
【问题描述】:
我如何获得视频高度,例如。像Stats for nerds 中显示的高度?视频的宽度可能为 1920 像素,但高度可能小于 1080 像素,我想通过 ajax 或 API 获得该高度
【问题讨论】:
标签: javascript ajax youtube-api jsonp
我如何获得视频高度,例如。像Stats for nerds 中显示的高度?视频的宽度可能为 1920 像素,但高度可能小于 1080 像素,我想通过 ajax 或 API 获得该高度
【问题讨论】:
标签: javascript ajax youtube-api jsonp
最简单的方法是使用oembed
例如http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&format=json 然后杰森给你
{"height": 344, "title": "Auto-Tune the News #8: dragons. geese. Michael Vick. (ft. T-Pain)", "author_url": "http:\/\/www.youtube.com\/user\/schmoyoho", "thumbnail_height": 360, "version": "1.0", "provider_url": "http:\/\/www.youtube.com\/", "type": "video", "width": 459, "provider_name": "YouTube", "thumbnail_url": "http:\/\/i.ytimg.com\/vi\/bDOYN-6gdRE\/hqdefault.jpg", "thumbnail_width": 480, "html": "\u003ciframe width=\"459\" height=\"344\" src=\"http:\/\/www.youtube.com\/embed\/bDOYN-6gdRE?feature=oembed\" frameborder=\"0\" allowfullscreen\u003e\u003c\/iframe\u003e", "author_name": "schmoyoho"}
更多信息http://apiblog.youtube.com/2009/10/oembed-support.html
或
【讨论】: