4

Vine中的视频可见时自动播放,Vine是如何实现的,有什么方法可以判断视频可见吗?

4

1 回答 1

4

嵌入代码添加了一个js文件。在该文件中,他们使用 setInterval 循环检查是否有任何 vine iframe 元素在可见视口中。如果它们可见,它们会通过 iframe 的 contentWindow 发送“播放”消息。目前检查代码为:

var topPosition = embeds[i].getBoundingClientRect().top;
if (topPosition > -300 && topPosition < document.documentElement.clientHeight) {

你可以看看他们控制这个的嵌入脚本(第 20-42 行):

https://platform.vine.co/static/scripts/embed.js

于 2014-07-20T21:45:41.140 回答