Sometimes, we want to get current YouTube video time with JavaScript
In this article, we’ll look at how to get current YouTube video time with JavaScript
How to get current YouTube video time with JavaScript?
To get current YouTube video time with JavaScript, we use the getCurrentTime
method.
For instance, we write
const ytPlayer = document.getElementById("movie_player");
ytPlayer.getCurrentTime();
to get the YouTube player with getElementById
.
Then we get the current time with the getCurrentTime
method.
Conclusion
To get current YouTube video time with JavaScript, we use the getCurrentTime
method.