0

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?

m0meni
  • 16,006
  • 16
  • 82
  • 141
  • I think you actually want the YouTube Data API. https://developers.google.com/youtube/v3/ – Brad Apr 01 '15 at 01:09
  • I don't think so because it says "The YouTube Data API (v3) lets you incorporate YouTube functionality into your own application." I just want to interact with the player already on youtube.com as if I were using the JS console. – m0meni Apr 01 '15 at 01:12
  • Oh, I misread. I thought you wanted the state of the video, not the player. – Brad Apr 01 '15 at 01:13

2 Answers2

1

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.

Bramha Ghosh
  • 6,504
  • 4
  • 30
  • 29
0

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

Community
  • 1
  • 1
m0meni
  • 16,006
  • 16
  • 82
  • 141