On a page with an embedded YouTube player, is it possible to tell which version of the player is being used (HTML5 or Flash)?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It turns out you can check for the existence/absence of certain properties on the player. The most obvious one is perhaps cueVideoByFlashvars
, so you can do:
var isHtml5Player = !player.cueVideoByFlashvars;
As Jeff mentions it's not great to have to rely on this as it could change at any time.
回答2:
There is no supported API for determining that information, and it's not likely that one will be added.
While I'm sure that there are some hacks that take advantage of subtle differences in the way AS3 and HTML5 video behave in response to certain API calls, or to find a way of inspecting the DOM, I wouldn't recommend coding anything that fragile into a production-quality application.