且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在尝试加载***视频之前,如何判断该视频是否可嵌入?

更新时间:2023-11-26 14:14:16

您提到的两个视频对我来说似乎是可以加载和播放的。例如,使用: Google代码游乐场,然后将视频插入选项标签

Both videos you mentioned appear to be loadable and playable for me. For example use: the google code playground and insert your videos into the option tags of the HTML.

不过,这里有一些提示。

Here's a few tips though.

  • Use the "v=2" parameter in your gdata request to use the current YT data API.
  • This blog post lists several additional restrictions that you may need to check for to determine if a video playable or embeddable.
  • Some videos can be embedded, but don't play. In that case the only thing you can do is to use the JavaScript PlayerAPI to look for a stateChange event that says that it's playing, and then use a setInterval to poll the video through getCurrentTime to find out if it is actually playing. This is a little crazy for most applications though.