Javascript YT Player getCurrentTime()返回0

Javascript YT Player getCurrentTime()返回0,javascript,reactjs,iframe,youtube-iframe-api,Javascript,Reactjs,Iframe,Youtube Iframe Api,我正在使用Youtube Iframe Api。我想得到每秒iframe的当前时间。但是,当我运行代码时,它总是返回“0”。以下是我正在使用的代码: setInterval(() => { var ts = player.getCurrentTime(); console.log(ts); }); 非常感谢您的帮助 谢谢

我正在使用Youtube Iframe Api。我想得到每秒iframe的当前时间。但是,当我运行代码时,它总是返回“0”。以下是我正在使用的代码:

setInterval(() => {
 var ts = player.getCurrentTime();
 console.log(ts);
});
非常感谢您的帮助
谢谢