如何获得 YouTube 视频纵横比 [英] How to get YouTube video aspect ratio

查看:26
本文介绍了如何获得 YouTube 视频纵横比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取 YouTube 视频的纵横比,以相应地调整播放器的大小.我正在使用 JavaScript 为 YT 播放器编程.

I'd like to get the aspect ratio of a YouTube video, to resize the player accordingly. I'm programming the YT player using JavaScript.

推荐答案

我建议点击 oembed url:

I would suggest hitting the oembed url:

https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v={videoID}&format=json

https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v={videoID}&format=json

这会为您提供公开视频的确切视频尺寸.不过,我不确定私人视频.它还会返回缩略图尺寸,在某些情况下似乎有所不同,因此请确保不要将它们混淆.

This gives you the exact video dimensions for videos that are public. I'm not sure about private videos though. It will also return thumbnail dimensions, which seem to be different im some cases, so just be sure to not mix them up.

这篇关于如何获得 YouTube 视频纵横比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆