【发布时间】:2013-03-13 16:21:26
【问题描述】:
onError 事件处理程序返回 event.data = 0,通常用于已删除或私有视频(尽管我尚未测试所有情况),而不是 YouTube IFrame API 参考 (https://developers.google.com/youtube/iframe_api_reference#Events) 上记录的错误值/p>
onError
如果播放器发生错误,则会触发此事件。 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 或更大。
【问题讨论】:
-
只是为了跟进,我使用 Chrome 开发工具中选择的 IFrame 选项调试了 Player API Demo 页面,它还返回给定视频的 event.data = 0 并返回
[object Object]因为代码在 onPlayerError 中不期望或防御返回值 0。所以我只能假设这是最近一段时间被引入 API 并且尚未解决的错误。鉴于这是现在为 YouTube API 报告这些问题的唯一方法,我希望对此做出回应。 -
这个错误在我发布时仍然存在。我试图播放视频,不管它有什么问题。奇怪的是,它在网站本身上是有效的。这也不是私人视频问题,因为我无需登录即可在 youtube 上观看视频。
标签: youtube-api