Thursday, April 19, 2012

[YouTube-API] Re: player.loadVideoById is not a function

Hello,

You're almost certainly running into an issue with variable scoping,
though without your full code it's not possible to tell.

A quick solution would be to use

event.target.loadVideoById()

from within your onPlayerStateChange() handler, since the YT.Player
instead is passed into all event handlers in the "target" property of
the handler's parameter.

Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev


On Apr 19, 7:52 am, cheeeze <marcelisod...@gmail.com> wrote:
> Hi !
> I hope you can help me . :-)
>
> When I want to play another video in the player, I've error : player.loadVideoById
> is not a function
>
> function onYouTubePlayerAPIReady(id) {
> player = new YT.Player('player', {
>     height: '390',
>     width: '640',
>     videoId: id,
>     playerVars: {
>      'autoplay': 0,
>      'rel': 0,
>
>     },
>     events: {
>       'onReady': onPlayerReady,
>       'onStateChange': onPlayerStateChange
>     }
>   });
>  }
> function onPlayerStateChange(event) {
>   if (event.data == YT.PlayerState.ENDED )
>   {
>  //onYouTubePlayerAPIReady('fTa3fj8O_M4'); // He recognize id but doesn't
> create the player
>   player.loadVideoById('fTa3fj8O_M4',0); // Not a function
>
>   }
>
> }
>
> *Thank you for your help, *
> *
> *
> *Cheeeze ;-)*

--
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