-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error handling (builds on #1191) #1197
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
740014c
Added better global log/error/warn functions.
heff 56cbe66
Started on better error handling and displaying in the UI when an err…
heff 11ca9cd
Updated flash tech to support new errors
heff 95d7e70
Exported ErrorDisplay
heff 2214207
Updated spinner to hide on all errors
heff 561c3f8
Added support for displaying a message for the error.
heff a742239
Fixed the error display to hide by default
heff c7ad732
Addressed comments in #1191
heff 81d7859
Removed unneeded comments
heff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
"start", | ||
"stop", | ||
"strictEqual", | ||
"test" | ||
"test", | ||
"sinon" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Display that an error has occurred making the video unplayable | ||
* @param {vjs.Player|Object} player | ||
* @param {Object=} options | ||
* @constructor | ||
*/ | ||
vjs.ErrorDisplay = vjs.Component.extend({ | ||
init: function(player, options){ | ||
vjs.Component.call(this, player, options); | ||
|
||
this.update(); | ||
player.on('error', vjs.bind(this, this.update)); | ||
} | ||
}); | ||
|
||
vjs.ErrorDisplay.prototype.createEl = function(){ | ||
var el = vjs.Component.prototype.createEl.call(this, 'div', { | ||
className: 'vjs-error-display' | ||
}); | ||
|
||
this.contentEl_ = vjs.createEl('div'); | ||
el.appendChild(this.contentEl_); | ||
|
||
return el; | ||
}; | ||
|
||
vjs.ErrorDisplay.prototype.update = function(){ | ||
if (this.player().error()) { | ||
this.contentEl_.innerHTML = this.player().error().message; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Custom MediaError to mimic the HTML5 MediaError | ||
* @param {Number} code The media error code | ||
*/ | ||
vjs.MediaError = function(code){ | ||
if (typeof code == 'number') { | ||
this.code = code; | ||
} else if (typeof code == 'string') { | ||
// default code is zero, so this is a custom error | ||
this.message = code; | ||
} else if (typeof code == 'object') { // object | ||
vjs.obj.merge(this, code); | ||
} | ||
|
||
if (!this.message) { | ||
this.message = vjs.MediaError.defaultMessages[this.code] || ''; | ||
} | ||
}; | ||
|
||
/** | ||
* The error code that refers two one of the defined | ||
* MediaError types | ||
* @type {Number} | ||
*/ | ||
vjs.MediaError.prototype.code = 0; | ||
|
||
/** | ||
* An optional message to be shown with the error. | ||
* Message is not part of the HTML5 video spec | ||
* but allows for more informative custom errors. | ||
* @type {String} | ||
*/ | ||
vjs.MediaError.prototype.message = ''; | ||
|
||
/** | ||
* An optional status code that can be set by plugins | ||
* to allow even more detail about the error. | ||
* For example the HLS plugin might provide the specific | ||
* HTTP status code that was returned when the error | ||
* occurred, then allowing a custom error overlay | ||
* to display more information. | ||
* @type {[type]} | ||
*/ | ||
vjs.MediaError.prototype.status = null; | ||
|
||
vjs.MediaError.errorTypes = [ | ||
'MEDIA_ERR_CUSTOM', // = 0 | ||
'MEDIA_ERR_ABORTED', // = 1 | ||
'MEDIA_ERR_NETWORK', // = 2 | ||
'MEDIA_ERR_DECODE', // = 3 | ||
'MEDIA_ERR_SRC_NOT_SUPPORTED', // = 4 | ||
'MEDIA_ERR_ENCRYPTED' // = 5 | ||
]; | ||
|
||
vjs.MediaError.defaultMessages = { | ||
1: 'You aborted the video playback', | ||
2: 'A network error caused the video download to fail part-way.', | ||
3: 'The video playback was aborted due to a corruption problem or because the video used features your browser did not support.', | ||
4: 'The video could not be loaded, either because the server or network failed or because the format is not supported.', | ||
5: 'The video is encrypted and we do not have the keys to decrypt it.' | ||
}; | ||
|
||
// Add types as properties on MediaError | ||
// e.g. MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4; | ||
for (var errNum = 0; errNum < vjs.MediaError.errorTypes.length; errNum++) { | ||
vjs.MediaError[vjs.MediaError.errorTypes[errNum]] = errNum; | ||
// values should be accessible on both the class and instance | ||
vjs.MediaError.prototype[vjs.MediaError.errorTypes[errNum]] = errNum; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per our side conversation, curious if this can be overridden the case of a custom errors plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it just be a matter of the message property on the object given to
player.error
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I think Tom and I got this figured out in chat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, good to have this here then for future purposes.