-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy patherror-display.js
More file actions
31 lines (26 loc) · 901 Bytes
/
error-display.js
File metadata and controls
31 lines (26 loc) · 901 Bytes
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
import videojs from 'video.js';
import { PLAYER_EVENT } from 'utils/consts';
const ErrorDisplay = videojs.getComponent('ErrorDisplay');
class CldErrorDisplay extends ErrorDisplay {
content() {
const error = this.player().error();
if (!error) return '';
const wrapper = videojs.dom.createEl('div', { className: 'cld-error-display-content' });
const msg = videojs.dom.createEl('span', { className: 'cld-error-message' });
if (error.isHtml) {
msg.innerHTML = this.localize(error.message);
} else {
msg.textContent = this.localize(error.message);
}
wrapper.appendChild(msg);
const refreshLink = msg.querySelector('.cld-error-refresh');
if (refreshLink) {
refreshLink.onclick = (e) => {
e.preventDefault();
this.player().trigger(PLAYER_EVENT.REFRESH);
};
}
return wrapper;
}
}
export default CldErrorDisplay;