onError 事件处理程序返回 event.data = 0,通常用于已删除或私有视频(尽管我尚未测试所有案例),而不是 YouTube IFrame API 参考 ( https://developers.google.com) 上记录的错误值。 com/youtube/iframe_api_reference#Events )
错误
如果播放器发生错误,则会触发此事件。API 会将事件对象传递给事件侦听器函数。该对象的数据属性将指定一个整数,用于标识发生的错误类型。可能的值为:
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 Demo 中测试此视频也返回 0(对于 AS3 播放器;选择 IFrame 时,它返回[object Object]
且不可检查)。
预期的错误代码将是 100 或更大。