-
Notifications
You must be signed in to change notification settings - Fork 7.5k
/
error-display.js
68 lines (61 loc) · 1.52 KB
/
error-display.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* @file error-display.js
*/
import Component from './component';
import ModalDialog from './modal-dialog';
import mergeOptions from './utils/merge-options';
/**
* A display that indicates an error has occurred. This means that the video
* is unplayable.
*
* @extends ModalDialog
*/
class ErrorDisplay extends ModalDialog {
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
constructor(player, options) {
super(player, options);
this.on(player, 'error', this.open);
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*
* @deprecated Since version 5.
*/
buildCSSClass() {
return `vjs-error-display ${super.buildCSSClass()}`;
}
/**
* Gets the localized error message based on the `Player`s error.
*
* @return {string}
* The `Player`s error message localized or an empty string.
*/
content() {
const error = this.player().error();
return error ? this.localize(error.message) : '';
}
}
/**
* The default options for an `ErrorDisplay`.
*
* @private
*/
ErrorDisplay.prototype.options_ = mergeOptions(ModalDialog.prototype.options_, {
pauseOnOpen: false,
fillAlways: true,
temporary: false,
uncloseable: true
});
Component.registerComponent('ErrorDisplay', ErrorDisplay);
export default ErrorDisplay;