Skip to content

Commit

Permalink
Make sure the error property is set before proxying through the tech.
Browse files Browse the repository at this point in the history
Some error events don't cause the error property on the video element to be set. In that case, handle the event like any other. Fixes videojs#1465.
  • Loading branch information
dmlap committed Sep 4, 2014
1 parent 0ac8bcd commit b8d27ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/js/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ vjs.Html5.prototype.setupTriggers = function(){
};

vjs.Html5.prototype.eventHandler = function(evt){
// In the case of an error, set the error prop on the player
// and let the player handle triggering the event.
if (evt.type == 'error') {
// In the case of an error on the video element, set the error prop
// on the player and let the player handle triggering the event. On
// some platforms, error events fire that do not cause the error
// property on the video element to be set. See #1465 for an example.
if (evt.type == 'error' && this.error()) {
this.player().error(this.error().code);

// in some cases we pass the event directly to the player
Expand Down
6 changes: 6 additions & 0 deletions test/unit/media.html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,9 @@ test('should return a maybe for mp4 on OLD ANDROID', function() {
vjs.IS_OLD_ANDROID = isOldAndroid;
vjs.Html5.unpatchCanPlayType();
});

test('error events may not set the errors property', function() {
equal(tech.error(), undefined, 'no tech-level error');
tech.trigger('error');
ok(true, 'no error was thrown');
});

0 comments on commit b8d27ef

Please # to comment.