Categories
JavaScript Answers

How to get current YouTube video time with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *