Javascript - 检测Youtube默认缩略图 [英] Javascript - Detect Youtube Default-Thumbnail

查看:139
本文介绍了Javascript - 检测Youtube默认缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法查看Youtube缩略图是否真的存在,或者Youtube是否只是将其替换为默认缩略图?

Is there any way to see if a Youtube Thumbnail really exists or Youtube just replaced it by the default thumbnail?

例如,没有此缩略图的视频:< a href =http://img.youtube.com/vi/G75WApUdYJ4/maxresdefault.jpg =nofollow> http://img.youtube.com/vi/G75WApUdYJ4/maxresdefault.jpg
和现有缩略图: http://img.youtube.com/vi /pkyLAWX5V30/maxresdefault.jpg

For example, a video without this thumbnail : http://img.youtube.com/vi/G75WApUdYJ4/maxresdefault.jpg And one with an existing thumbnail : http://img.youtube.com/vi/pkyLAWX5V30/maxresdefault.jpg

故事:
我只是尝试使用Youtube的maxresdefault-Thumbnails作为我的Media-Player-Page的背景。
使用普通图像工作正常但是对于任何原因,一些Youtube视频没有maxresdefault-Thumbnail。如果我加载这个图像,我只得到一个小的默认缩略图,这在FullHD屏幕上并不是真的很有趣。

Story: I just tried to use Youtube's maxresdefault-Thumbnails as background for my "Media-Player-Page". Using normal images works fine but for any reasom some Youtube Videos don't have a maxresdefault-Thumbnail. If i load this image I just get the small default Thumbnail which isn't really enjoyable on a FullHD Screen.

推荐答案

而不是提供默认图片,您可以使用 0.jpg 1.jpg 2.jpg ,或 3.jpg (参见如何从YouTube API获取YouTube视频缩略图?

Rather than serving up the default image, you could use 0.jpg, 1.jpg, 2.jpg, or 3.jpg (see How do I get a YouTube video thumbnail from the YouTube API?).

如果这不能满足您的需求,您可以比较每个图像的Base64编码,如本答案中所定义:获取图像JavaScript中的数据?

If that doesn't work for your needs, you could compare the Base64 encoding of each image, as defined in this answer: Get image data in JavaScript?

这篇关于Javascript - 检测Youtube默认缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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