Optimize status display a little.

master
Icedream 2018-08-24 11:15:41 +02:00
parent 4f947e92cf
commit 149812e1cb
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
2 changed files with 18 additions and 5 deletions

View File

@ -15,10 +15,13 @@ window.addEventListener('load', () => {
statusContainer.appendChild(statusContent); statusContainer.appendChild(statusContent);
document.body.appendChild(statusContainer); document.body.appendChild(statusContainer);
function showStatus(text) { function showStatus() {
if (!(style['status--visible'] in statusContainer.classList)) { if (!(style['status--visible'] in statusContainer.classList)) {
statusContainer.classList.add(style['status--visible']); statusContainer.classList.add(style['status--visible']);
} }
}
function setStatus(text) {
statusContent.innerText = text; statusContent.innerText = text;
} }
@ -52,19 +55,25 @@ window.addEventListener('load', () => {
player.initialize(playerContainer, url, autoplay); player.initialize(playerContainer, url, autoplay);
player.on('error', (e) => { player.on('error', (e) => {
showStatus(`Error: ${e}`); showStatus();
setStatus(`Error: ${e}`);
}); });
player.on('bufferEmpty', () => { player.on('bufferEmpty', () => {
showStatus('We ran out of wood!'); setStatus('We ran out of wood!');
}); });
player.on('bufferStalled', () => { player.on('bufferStalled', () => {
showStatus('We are waiting for more wood…'); setStatus('We are waiting for more wood…');
}); });
player.on('bufferLoaded', () => { player.on('bufferLoaded', () => {
showStatus('Almost there…'); setStatus('Almost there…');
});
player.on('playbackWaiting', () => {
showStatus();
setStatus('Waiting for the workers to arrive…');
}); });
player.on('playbackPlaying', () => { player.on('playbackPlaying', () => {

View File

@ -7,6 +7,7 @@ fullscreen()
html html
background: #000 background: #000
color: #fff
body body
background: transparent background: transparent
@ -30,6 +31,9 @@ body
opacity: 0 opacity: 0
z-index: 10 z-index: 10
&.status__inner
background: rgba(0, 0, 0, .5)
&.status--visible &.status--visible
opacity: 1 opacity: 1