onError事件处理程序返回event.data = 0,通常用于已删除或私有的视频(虽然我尚未测试所有案例),而不是YouTube IFrame API参考文档中记录的错误值(https://developers.google.com/youtube/iframe_api_reference#Events )
的onError
如果播放器中发生错误,则会触发此事件。 API将事件对象传递给事件侦听器函数。该对象的data属性将指定一个整数,用于标识发生的错误类型。可能的值有:
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!
这是在Mac OS X上,Chrome,Firefox和Safari中发生的最新版本。以下是移除视频的链接,该视频在使用IFrame API嵌入时会返回此错误代码:http://www.youtube.com/watch?v=-TefH2gu9-o
在Player API演示中测试此视频也会返回0(对于AS3播放器;选择IFrame时,它返回[object Object]
并且无法检查)。
预期的错误代码为100或更高。
答案 0 :(得分:1)
当HTML5播放用于视频ID“-TefH2gu9-o”时,将返回错误代码100,但是,当使用Flash播放时,错误地返回0。我将跟进内部工程团队。
回复:
鉴于这是向YouTube报告这些问题的唯一方式 API现在......
我们非常鼓励人们使用公共问题跟踪器来处理与YouTube API相关的错误报告,并且只询问Stack Overflow上的编程/技术问题(与Stack Overflow的更大任务一致)。有关如何在http://apiblog.youtube.com/2012/09/the-youtube-api-on-stack-overflow.html
报告错误/功能请求的详细信息