Skip to content

Commit

Permalink
Merge pull request #280 from OwenEdwards/handle-youtube-errors
Browse files Browse the repository at this point in the history
Convert YouTube errors into text, to improve error reporting.
  • Loading branch information
eXon committed Sep 27, 2015
2 parents ccf5145 + cab1e0a commit cd70a1a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,31 @@
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);
}
}
});

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'];
Expand Down

0 comments on commit cd70a1a

Please sign in to comment.