最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Youtube API returning current time - Stack Overflow

programmeradmin1浏览0评论

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 pletion.

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.

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.

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 pletion.

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.

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.

Share Improve this question edited Mar 8, 2012 at 17:01 user1228 asked Mar 1, 2012 at 21:46 BankzillaBankzilla 2,0963 gold badges25 silver badges52 bronze badges 3
  • You can answer below, then select that answer is correct. That way you can close this question out. – user1228 Commented Mar 8, 2012 at 17:02
  • I'm using the youtube frame api and player.getCurrentTime() is working fine for me... even if I get a console error "player.getCurrentTime is not a function". – httpete Commented Mar 13, 2012 at 16:52
  • I couldn't do it at the time due to needing to wait 2 days – Bankzilla Commented Mar 14, 2012 at 0:14
Add a ment  | 

1 Answer 1

Reset to default 4

getCurrentTime is also available in youtube iframe source.

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.

发布评论

评论列表(0)

  1. 暂无评论