James P
James P

Reputation: 848

How to get reference to Youtube Iframe API player throughout Angular app

I've been digging around the Stack Overflow threads, and can't seem to find this issue addressed exactly. I set up and Angular app, and I would like to be able to call methods on a YouTube API from within multiple controllers and directives (such as playVideo() and pauseVideo() etc)

The video will be persistent throughout the site.

I initially set up the API via a service and subsequently injected it into the various controllers. I used a $rootscope.$broadcast to send a message when the player was ready, but I could never get the actual player returned, just an empty object.

To make matters worse, I rebuilt the site statically so have no example code to show here, but was hoping someone might be able to outline the basic procedure here.

Thanks, James

Upvotes: 1

Views: 374

Answers (1)

Ibrahim Ulukaya
Ibrahim Ulukaya

Reputation: 12877

YouTube Topic explorer uses iframe inside the angular script. You can basically create your own function or directive to use the iFrame.

Upvotes: 2

Related Questions