There is no event that you can listen for that serves the same
purpose as the onYouTubePlayerAPIReady callback.
I can't tell you the specific JavaScript to use off the top of my
head, but I think you should be able to test to see if
window.onYouTubePlayerAPIReady is already defined, and if so, save a
reference to the existing function and then write your own function
which does the necessary initialization you want, and calls the
reference to the previous function as its last step. That assumes that
your callback is registered after the callback on the page; if it's
the other way around, then the callback on the page will almost
certainly overwrite yours.
Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev
On Feb 21, 3:32 pm, Tama Pugsley <t...@springload.co.nz> wrote:
> I'm writing a small snippet of code to track video loads, plays, pauses
> etc. with Google Analytics. Once it's finished I'd like to release it so
> others can use it too. However in order to know when the API has loaded I
> need to define 'onYouTubePlayerAPIReady'. This works great on a test page
> but is going to break when the snippet is dropped into a page that has
> already defined 'onYouTubePlayerAPIReady'.
>
> I've thought about kicking off an setInterval to wait for the presence of
> 'YT' but it seems dirty. Is there an event I can listen for instead? I've
> had a look through the minified api code and can't see anything obvious.
> Ideas?
--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment