6
votes

The onError event handler returns event.data = 0, generally for removed or private videos (although I haven't tested all cases yet), rather than the documented error values on the YouTube IFrame API Reference (https://developers.google.com/youtube/iframe_api_reference#Events)

onError

This event fires if an error occurs in the player. The API will pass an event object to the event listener function. That object's data property will specify an integer that identifies the type of error that occurred. Possible values are:

 2 – The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.
 5 – The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.
 100 – The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.
 101 – The owner of the requested video does not allow it to be played in embedded players.
 150 – This error is the same as 101. It's just a 101 error in disguise!

This is happening on Mac OS X, in Chrome, Firefox and Safari, latest versions. Here is a link to a removed video that returns this error code when embedded using the IFrame API: http://www.youtube.com/watch?v=-TefH2gu9-o

Testing this video in the Player API Demo also returns 0 (for the AS3 player; when selecting IFrame, it returns [object Object] and is not inspectable).

The expected error code would be 100 or greater.

1
Just to follow up, I debugged the Player API Demo page with the IFrame option selected in Chrome Dev Tools, it also returns event.data = 0 for the given video and returns [object Object] because the code in onPlayerError doesn't expect or defend against a value of 0 being returned. So I can only assume that this is a bug that was introduced into the API some time recently and has yet to be resolved. Given that this is the only way to report these issues for the YouTube API now, I'd appreciate a response on this.Mina Mikhail
The bug still exists at the time I am posting this. I tried to play the video regardless and its faulty. Weird that on the website itself it works. Its also not a private video problem because I can view the video on youtube without being loggedin.Discipol

1 Answers

1
votes

The error code of 100 is returned when HTML5 playback is used for video id "-TefH2gu9-o", but yes, when Flash playback is used, 0 is returned incorrectly. I'll follow up with the internal engineering team about that.

Re:

Given that this is the only way to report these issues for the YouTube API now...

We would very much encourage people to use the public issue tracker for bug reports related to the YouTube API, and only ask programming/technical questions on Stack Overflow (in keeping with Stack Overflow's larger mission). There are details about how to report bugs/feature requests at http://apiblog.youtube.com/2012/09/the-youtube-api-on-stack-overflow.html