获取 YouTube 视频尺寸(宽度/高度) [英] Get YouTube Video dimensions (width/height)
问题描述
我正在尝试获取 YouTube 视频的大小.我正在使用 Gdata API 调用来检索基本信息(标题、URL、缩略图和类别),但我找不到视频尺寸.
I’m trying to get the size of a YouTube video. I’m using a Gdata API call to retrieve the basic informations (title, URLs, thumbnails and categories) but I can’t find the video dimensions.
我正在使用 YouTube 数据 API 服务器端调用在网站上嵌入一些视频,如下所示:http://gdata.youtube.com/feeds/api/videos/z_AbfPXTKms?0=v&1=2&alt=json.不幸的是,没有关于视频尺寸的可靠信息(所有预览图像都是 4/3 比例,即使是宽屏视频).
I’m embedding some videos on a website using YouTube Data API server-side calls like this: http://gdata.youtube.com/feeds/api/videos/z_AbfPXTKms?0=v&1=2&alt=json. Unfortunately, there is no reliable information on video dimensions (all the preview images are in 4/3 rate even with widescreen videos).
我想要完成的是将视频完全适合播放器;播放器宽度是固定的,所以我只需要原始尺寸或至少是比例.
What I am trying to accomplish is to fit the video exactly into the player; the player width is fixed, so I just need the original dimensions or at least the proportion.
有没有办法使用 Youtube API 检索此类数据?
Is there any way to retrieve this kind of data with the Youtube API?
(我的后备计划是将播放器大小设置为 4/3 并且从不回头,但感谢任何帮助!)
(My fallback plan is to set the player size to 4/3 and never watch back, but any help is appreciated!)
推荐答案
您还可以通过 YouTube 的 oEmbed 实现获得它.示例:
You can also get it thanks to the oEmbed implementation of YouTube. Example:
https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=hUvbb_eUP84&format=xml
format=json
也被接受.
这篇关于获取 YouTube 视频尺寸(宽度/高度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!