From cab1e0a1fe30c653732f9f13e5b40cad0619cdfc Mon Sep 17 00:00:00 2001 From: Owen Edwards Date: Tue, 9 Jun 2015 18:50:17 -0700 Subject: [PATCH] Convert YouTube errors into text, for error reporting. --- src/youtube.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/youtube.js b/src/youtube.js index 76fabbc1..48d1a917 100644 --- a/src/youtube.js +++ b/src/youtube.js @@ -624,7 +624,8 @@ e.target.vjsTech.onPlaybackQualityChange(e.data); }, onError: function(e) { - e.target.vjsTech.onError(e.data); + var err = videojs.Youtube.errorMessages[e.data] || 'Unknown YouTube error, code ' + e.data; + e.target.vjsTech.onError(err); } } }); @@ -632,6 +633,22 @@ this.ytplayer.vjsTech = this; }; + // See https://developers.google.com/youtube/iframe_api_reference#Events + videojs.Youtube.errorMessages = { + 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: 'The owner of the requested video does not allow it to be played in embedded players.' + }; + + // Transform a JavaScript object into URL params videojs.Youtube.makeQueryString = function(args) { var array = ['modestbranding=1'];