Youtube API返回当前时间 [英] Youtube API returning current time

查看:136
本文介绍了Youtube API返回当前时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用youtube iframe api,似乎无法在文档或google上找到任何引用如何获取当前媒体完成时返回值的内容。

I'm using the youtube iframe api and can't seem to find anything in the documentation or on google that references how to get the returned values on current media completion.

我需要构建一个脚本,我可以在时间变量中过去,当变量与播放的当前时间匹配时,可以触发事件。

I'm needing to build a script where I can past in time variables, in which when the variable matches up with the current time played an event can be triggered.

我知道在embed API中有一个, player.getCurrentTime():Number 但似乎不是iframe API的一个。我敢肯定有人会注意到这一点。

I know in the embed API there is one, player.getCurrentTime():Number but doesn't seem to be one for the iframe API. I'm sure someone would of noticed this before.

推荐答案

getCurrentTime 也可以在youtube iframe源中使用。

getCurrentTime is also available in youtube iframe source.

要获取当前时间码,我使用了math.floor。

To get current time code, I used a math.floor.

time = Math.floor(Video.YTPlayer.getCurrentTime());

这将始终返回整数,并将不断向下舍入数字。

This will always return whole numbers and will constantly round down numbers to its whole.

这篇关于Youtube API返回当前时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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