Reputation: 517
I am using the Youtube API to show subtitles below a video. Whenever the video is stopped/started or the position moved I will take the time using getCurrentTime(), however it only provides the value in full seconds. When I want to have fast changes in the subtitles, I need a more precise way to get the time, is there any way to get it in milliseconds?
Upvotes: 2
Views: 1022
Reputation: 36
The getTime() function is supposed to return the current time of the video in second followed by milliseconds, such as 2.1313131 when the video is paused early. The modified code snippit of the api's demo shows this in the console. I'm unsure if you're setting any time interval, or accidentally converting the time into integers.
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
var videotime = 0;
event.target.playVideo();
function updateTime() {
console.log(player.getCurrentTime());
}
timeupdater = setInterval(updateTime, 0);
}
Upvotes: 1