m0meni
m0meni

Reputation: 16445

How do you get the state of a youtube video on youtube.com?

I'm trying to make a chrome extension that needs the state of the youtube video player, and I'm aware of the existence of the API but my attempts to actually use it have been fruitless. Can someone point me in the right direction?

Upvotes: 0

Views: 83

Answers (2)

m0meni
m0meni

Reputation: 16445

What I was looking for is that you have to call the API methods on this div and that wasn't made clear in the docs.

document.getElementById('movie_player');

Moreover if anyone else ends up here go ahead an read this:

Insert code into the page context using a content script

Upvotes: 0

Bramha Ghosh
Bramha Ghosh

Reputation: 6544

You'll want to subscribe to the onStateChange event as described here: https://developers.google.com/youtube/js_api_reference?csw=1#SubscribingEvents

The states of the player are described in the documentation for the onStateChange event on the same page.

Upvotes: 1

Related Questions