Tuesday, January 10, 2012

[YouTube-API] Problem: TypeError: '[]' is not a valid argument for 'Function.prototype.apply' (evaluating 'a.args')

Hey there,

I am having trouble with the youtube iframe api.
I am working on a site which is about distributing videos and
therefore it must be possible to have multiple youtube videos on one
page. when the page is loaded the user will see a custom image to
click on (image is not from youtube). When the image is clicked, the
image disappears and the video is loaded. That works so far. But the
video should then start playing right away. Instead I see the youtube
play icon in the middle of the video and an error message in the
console. "TypeError: '[]' is not a valid argument for
'Function.prototype.apply' (evaluating 'a.args')"

I narrowed down which line in my code causes this error:
event.target.playVideo();

when i write event.target.playVideo("test"); the error message says:
"TypeError: '["test"]' is not a valid argument for
'Function.prototype.apply' (evaluating 'a.args')" so it must be that
line.

For testing, i checked the example code from
http://code.google.com/intl/de-DE/apis/youtube/iframe_api_reference.html
and that one works fine.
I multiplied part of the example code so that there were two videos on
one page and it worked. I can see two videos and they start playing
right away.

Of course I also tried using only one video on a page, but i still
receive the error.

What am i possibly doing wrong?

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