- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想确切地知道 YouTube 视频是宽屏的还是不使用 v3 API。有很多旧视频有 4:3 的比例,所以我需要检测这一点。
这可以通过 API v2 实现,不过现在已经正式退役了。这是 API v3 docs .
API 调用看起来像这样:
https://www.googleapis.com/youtube/v3/videos?id=[VIDEOID]&part=snippet&key=[DEVELOPERKEY]
此外,缩略图数据始终返回 4:3 的尺寸,因此这无济于事。这是一个例子:
[thumbnails] => Array
(
[default] => Array
(
[url] => https://i.ytimg.com/vi/nnnnnnnnn/default.jpg
[width] => 120
[height] => 90
)
...
)
有什么想法吗?
(我目前通过分析缩略图中的像素来破解 4:3 视频中明显的黑条。)
这是一个 4:3 比例的示例视频:
https://www.youtube.com/watch?v=zMJ-Dl4eJu8 (老武打视频)
16:9 中的一个:
https://www.youtube.com/watch?v=7O2Jqi-LhEI (一个新的锻炼视频)
更新:一个有前途的建议是探索fileDetails.videoStreams[].aspectRatio
,但似乎只有视频所有者可以使用。否则请求 fileDetails
会导致
The request cannot access user rating information. This error may occur because the request is not properly authorized
最佳答案
如果您愿意使用 API V3 以外的其他方法,那么我相信可以通过 oEmbed API 实现。
http://www.youtube.com/oembed?url={VIDEO_URL}&format=json
像这样:
http://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=zMJ-Dl4eJu8&format=json
会产生:
{
"provider_url":"https:\/\/www.youtube.com\/",
"thumbnail_url":"https:\/\/i.ytimg.com\/vi\/zMJ-Dl4eJu8\/hqdefault.jpg",
"thumbnail_height":360,
"height":344,
"type":"video",
"version":"1.0",
"html":"\u003ciframe width=\"459\" height=\"344\" src=\"https:\/\/www.youtube.com\/embed\/zMJ-Dl4eJu8?feature=oembed\" frameborder=\"0\" allowfullscreen\u003e\u003c\/iframe\u003e",
"author_name":"hadronica2",
"width":459,
"provider_name":"YouTube",
"author_url":"https:\/\/www.youtube.com\/user\/hadronica2",
"title":"Aikido - Kazuo Chiba sensei - 1\u00ba part",
"thumbnail_width":480
}
在您给出的示例中,输出如下:
http://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=zMJ-Dl4eJu8&format=json
Width: 459
Height: 344
Ratio: w/h = 1.3343 = 4:3 (ish)
http://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=zMJ-Dl4eJu8&format=json
Width: 480
Height: 270
Ratio: w/h = 1.7777 = 16/9
这似乎适用于您提供的示例。
关于php - 确定 YouTube 视频是否为宽屏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31188142/
如何从 Android-Native-Screen 打开 flutter 屏幕? 我开了一个 Android-Native-Screen 从现有我们 flutter 项目 . 所以,在 Android
有人知道如何使用 java 和 google chrome 最大化 selenium webdriver 窗口吗? 我已经尝试过一些命令,例如maximize () window (),但没有成功。
Redmi A65 智能电视今天正式开卖,4K 超高清大屏 + 立体声扬声器,到手价 2599 元。 IT之家了解到,Redmi A65 智能电视搭载了一块 65 英寸 4K 屏,支持 HDR
9 月 26 日消息小米电视大师「至尊纪念版」将在 9 月 29 日发布,根据今天小米集团大家电部总经理李肖爽放出的海报显示,小米电视大师至尊版有两款。 小米电视大师「至尊纪念版」是小米首款
华为手环 6 今日在海外正式发布,英文名 Band 6。这款产品是华为手环 4 的升级版,屏幕尺寸由 0.96 英寸升级为 1.47 英寸 AMOLED 屏,分辨率 194 x 368。该手环外形类
我是一名优秀的程序员,十分优秀!