The target property of the passed in event should always contain a
reference to the YT.Player object that triggered the event. That's
part of our documented API, and I'm not aware of any plans to change
that behavior.
However, you shouldn't rely on being able to read the internal
structure of the YT.Player object directly, as that's deliberately
opaque and subject to change at any time. You should use the supported
Player API methods to interact with YT.Player instead.
Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev
On Jan 19, 1:50 pm, misterfancypants <misterfancypa...@gmail.com>
wrote:
> When I started using the iframe embed API a few weeks ago, I noticed
> some apparently undocumented (but helpful) behavior in the onReady and
> onStateChange events. This behavior changed somewhat when the iframe
> player insertion behavior was altered a couple of days ago (http://
> groups.google.com/group/youtube-api-gdata/browse_thread/thread/
> cba53817e843603d/1476293b1b119d77#1476293b1b119d77).
>
> When I log the data that is passed as an argument to my onReady and
> onStateChange callbacks, instead of just the player state, as the
> documentation suggests, I get a large object in this basic structure
> (edited down to the high points):
>
> {
> data : 5,
> target : a : { ...},
> ...
> d : {
> ...
> duration : 5,
> muted : false,
> ...
> videoData : {
> title : "My Title",
> video_id : "noqHQKqrDrr"
> },
> ...
> }
> ...
>
> }
>
> But, up until iframe insertion changes a couple days ago, I was
> getting almost the same thing, but the object "d" was "f" :
>
> {
> data : 5,
> target : a : { ...},
> ...
> f : {
> ...
> duration : 5,
> muted : false,
> ...
> videoData : {
> title : "My Title",
> video_id : "noqHQKqrDrr"
> },
> ...
> }
> ...
>
> }
>
> The change is minor — no problem there. But, here's why this all
> matters: the "target" object is extremely useful in situations where
> there is more than one video on a page. It is vital, in that case, for
> the callback to know for which video the state is being broadcast.
>
> I realize that this API is still experimental, but it would be good to
> get more info on the passed event callback arguments, find out if
> there is / will be documentation, and see if there's any feel for this
> feature's stability (I hope it sticks around!).
>
> Thanks!
--
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