【问题标题】:Return Embed YouTube Current Time返回嵌入 YouTube 当前时间
【发布时间】:2015-04-01 21:45:40
【问题描述】:

我知道这个问题已经有been asked before,答案指向Google's iFrame API Reference的代码player.getCurrentTime():Number,但是我到底把那个JS代码放在哪里呢?

每当按下<button class="gettime"> 时,我想将当前时间附加到<p class="displaytime">。

我已经构建了 YT.Player 对象,并且能够使用外部按钮触发播放和暂停,但无法获取当前时间。

这是我对 jQuery 的试用:

$('.gettime').click(function() {
$('.displaytime').append(player.getCurrentTime():Number);
}); 

我想我不能直接附加代码? 谢谢!

【问题讨论】:

  • 向我们展示播放器的完整代码

标签: jquery youtube-api


【解决方案1】:

好的,知道了。

 $('.gettime').click(function(){
    var currenttime =  player['player1'].getCurrentTime();
    $('.displaytime').append(currenttime);
    });

我猜 API 参考代码中的 :Number 是为了告诉输出是一个数字。

【讨论】:

    猜你喜欢
    • 2012-03-20
    • 1970-01-01
    • 2021-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    • 2021-11-04
    相关资源
    最近更新 更多