Skip to content

Commit

Permalink
Add detail to video errors in Chrome
Browse files Browse the repository at this point in the history
This makes use of a new field added to Chrome 59.

Change-Id: I1b68e803967cfd7cfb64cea26458d0f3ef8a27c1
  • Loading branch information
joeyparrish committed Jun 20, 2017
1 parent 7a5991a commit 651b32a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
38 changes: 38 additions & 0 deletions externs/mediaerror.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/**
* @fileoverview Externs for MediaError properties not in the Closure compiler.
*
* @externs
*/


/**
* A new field in the living standard to give a more informative diagnostic
* message about the error.
* @type {string}
*/
MediaError.prototype.message;


/**
* A Microsoft Edge & IE extension to add a Windows error code.
* @type {number}
*/
MediaError.prototype.msExtendedCode;
4 changes: 0 additions & 4 deletions externs/msmediakeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,3 @@ MSMediaKeyError.MS_MEDIA_KEYERR_HARDWARECHANGE;

/** @type {number} */
MSMediaKeyError.MS_MEDIA_KEYERR_DOMAIN;


/** @type {number} */
MediaError.prototype.msExtendedCode;
5 changes: 4 additions & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2558,11 +2558,14 @@ shaka.Player.prototype.onVideoError_ = function(event) {
extended = extended.toString(16);
}

// Extra error information from Chrome:
var message = this.video_.error.message;

this.onError_(new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.VIDEO_ERROR,
code, extended));
code, extended, message));
};


Expand Down
1 change: 1 addition & 0 deletions lib/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ shaka.util.Error.Code = {
* The video element reported an error.
* <br> error.data[0] is a MediaError code from the video element.
* <br> On Edge & IE, error.data[1] is a Microsoft extended error code in hex.
* <br> On Chrome, error.data[2] is a string with details on the error.
*/
'VIDEO_ERROR': 3016,

Expand Down

0 comments on commit 651b32a

Please sign in to comment.