more dumb stuff

This commit is contained in:
Evert Prants 2022-04-09 22:53:14 +03:00
parent 4a2b79d4d0
commit 0502504d07
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 41 additions and 8 deletions

View File

@ -52,14 +52,23 @@ export class Game {
if (array[1] === 'join') { if (array[1] === 'join') {
this.party.push(name); this.party.push(name);
this.chat.addMessage(`Joined party of user "${name}".`);
} }
if (array[1] === 'leave') { if (array[1] === 'leave') {
this.party.splice(this.party.indexOf(name), 1); this.party.splice(this.party.indexOf(name), 1);
this.chat.addMessage(`Left party of user "${name}".`);
} }
if (array[1] === 'clear') { if (array[1] === 'clear') {
this.party.length = 0; this.party.length = 0;
this.chat.addMessage('Cleared party list.');
}
if (array[1] === 'list') {
this.chat.addMessage(
`You have joined the watch party of: ${this.party.join(', ')}`,
);
} }
localStorage.setItem('party', this.party.join('|')); localStorage.setItem('party', this.party.join('|'));
@ -178,7 +187,9 @@ export class Game {
(player as PlayerEntity).addChat(event.message); (player as PlayerEntity).addChat(event.message);
} }
this.chat.addMessage(event.sender.display_name, event.message); this.chat.addMessage(event.message, event.sender.display_name);
// experimental stuff
this.experimentalPlayerCmd(event.message, event.sender.display_name); this.experimentalPlayerCmd(event.message, event.sender.display_name);
}); });
} }
@ -195,16 +206,23 @@ export class Game {
} else { } else {
this.videoTest.play(); this.videoTest.play();
} }
return;
} }
if (message.startsWith('!stop') || message.startsWith('!pause')) { if (message.startsWith('!stop') || message.startsWith('!pause')) {
this.videoTest.stop(); this.videoTest.stop();
return;
} }
if (message.startsWith('!volume')) { if (message.startsWith('!volume')) {
const [cmd, vol] = message.split(' '); const [cmd, vol] = message.split(' ');
if (!vol) {
this.chat.addMessage(
`Current volume: ${Math.floor(this.videoTest.video.volume * 100)}`,
);
return;
}
this.videoTest.setVolume(parseInt(vol.replace('%', ''), 10)); this.videoTest.setVolume(parseInt(vol.replace('%', ''), 10));
} }
// end of
} }
} }

View File

@ -137,7 +137,7 @@ export class Chat {
this._rehide = rehide; this._rehide = rehide;
} }
public addMessage(sender: string, message: string, meta?: any) { public addMessage(message: string, sender?: string, meta?: any) {
const msg = document.createElement('div'); const msg = document.createElement('div');
const msgSender = document.createElement('div'); const msgSender = document.createElement('div');
const msgTime = document.createElement('div'); const msgTime = document.createElement('div');
@ -148,7 +148,7 @@ export class Chat {
msgSender.classList.add('chat__message-sender'); msgSender.classList.add('chat__message-sender');
msgContent.classList.add('chat__message-content'); msgContent.classList.add('chat__message-content');
msg.append(msgTime, msgSender, msgContent); msg.append(msgTime);
const stamp = meta?.time ? new Date(meta.time) : new Date(); const stamp = meta?.time ? new Date(meta.time) : new Date();
@ -157,9 +157,20 @@ export class Chat {
.getMinutes() .getMinutes()
.toString() .toString()
.padStart(2, '0')}`; .padStart(2, '0')}`;
msgSender.innerText = sender;
msgSender.style.setProperty('--name-color', this.getNameColor(sender)); // optional sender
if (sender) {
msgSender.innerText = sender;
msgSender.style.setProperty('--name-color', this.getNameColor(sender));
msg.append(msgSender);
}
// optional color for content
if (meta?.color) {
msgSender.style.setProperty('--name-color', meta.color);
}
msgContent.innerText = message; msgContent.innerText = message;
msg.append(msgContent);
// const bottomed = this._history.scrollTop ,this._history.scrollHeight; // const bottomed = this._history.scrollTop ,this._history.scrollHeight;
this._history.append(msg); this._history.append(msg);

View File

@ -35,6 +35,8 @@ export class VideoPlayer {
this.video.pause(); this.video.pause();
this.video.src = undefined; this.video.src = undefined;
}); });
this.video.volume = 0.8;
} }
public setSource(source: string, autoplay = false) { public setSource(source: string, autoplay = false) {
@ -60,9 +62,11 @@ export class VideoPlayer {
this.hls.stopLoad(); this.hls.stopLoad();
} }
}); });
this.hls.on(Hls.Events.ERROR, (e, d) => { this.hls.on(Hls.Events.ERROR, (e, d) => {
this.playable = false; if (d.fatal) {
// if (!d.fatal) return; this.playable = false;
}
}); });
return; return;
} }