From 35f5664933bf11193917c096deb3a83a6fda7650 Mon Sep 17 00:00:00 2001 From: Solomon Cammack Date: Sat, 19 Nov 2022 22:12:59 +0000 Subject: [PATCH] Add buffer and adjust some styling --- .../src/components/broadcast/ListenInBug.vue | 2 +- .../src/components/broadcast/PlayerAudio.vue | 50 +++++++++++-------- .../broadcast/roots/IngameCommsOverlay.vue | 14 ++++-- website/src/router/broadcast.js | 3 +- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/website/src/components/broadcast/ListenInBug.vue b/website/src/components/broadcast/ListenInBug.vue index 16a2d22a..5da2296c 100644 --- a/website/src/components/broadcast/ListenInBug.vue +++ b/website/src/components/broadcast/ListenInBug.vue @@ -26,7 +26,6 @@ export default { display: flex; font-size: 32px; border-bottom: 4px solid transparent; - padding-top: 2px; } .listen-in .team-logo { height: 100%; @@ -34,6 +33,7 @@ export default { } .listen-in .text { padding: 2px 8px; + padding-top: 4px; text-transform: uppercase; } diff --git a/website/src/components/broadcast/PlayerAudio.vue b/website/src/components/broadcast/PlayerAudio.vue index 7e5d7b55..18f1d857 100644 --- a/website/src/components/broadcast/PlayerAudio.vue +++ b/website/src/components/broadcast/PlayerAudio.vue @@ -16,41 +16,47 @@ import { cleanID } from "@/utils/content-utils"; export default { name: "PlayerAudio", - props: ["broadcast", "taskKey"], + props: ["broadcast", "taskKey", "buffer"], sockets: { async audio(room, { data, user }) { if (room !== this.roomKey) return; - if (this.muted) return; - this.lastPacketTime[user] = Date.now(); + setTimeout(async () => { + if (this.muted) return; + this.lastPacketTime[user] = Date.now(); - if (!this.players[user]) { - this.players[user] = new PCMPlayer({ - encoding: "32bitFloat", - channels: 2, - sampleRate: 48000, - flushingTime: 1000 - }); - } + if (!this.players[user]) { + this.players[user] = new PCMPlayer({ + encoding: "32bitFloat", + channels: 2, + sampleRate: 48000, + flushingTime: 1000 + }); + } - if (!this.decoders[user]) { - this.decoders[user] = new OpusDecoderWebWorker({ channels: 2 }); - } + if (!this.decoders[user]) { + this.decoders[user] = new OpusDecoderWebWorker({ channels: 2 }); + } - await this.decoders[user].ready; + await this.decoders[user].ready; - const { channelData, samplesDecoded } = await this.decoders[user].decodeFrame(data); - if (channelData) { - this.players[user].feed({ channelData, length: samplesDecoded }); - } + const { channelData, samplesDecoded } = await this.decoders[user].decodeFrame(data); + if (channelData) { + this.players[user].feed({ channelData, length: samplesDecoded }); + } + }, this.buffer || 0); }, audio_member_list(room, memberList) { if (room !== this.roomKey) return; - this.memberList = memberList; + setTimeout(() => { + this.memberList = memberList; + }, this.buffer || 0); }, audio_job_status(room, status) { if (room !== this.roomKey) return; - console.log("status", this.taskKey, status); - this.status = status; + setTimeout(() => { + console.log("status", this.taskKey, status); + this.status = status; + }, this.buffer || 0); } }, data: () => ({ diff --git a/website/src/components/broadcast/roots/IngameCommsOverlay.vue b/website/src/components/broadcast/roots/IngameCommsOverlay.vue index 0b4d526b..49e2707c 100644 --- a/website/src/components/broadcast/roots/IngameCommsOverlay.vue +++ b/website/src/components/broadcast/roots/IngameCommsOverlay.vue @@ -1,14 +1,15 @@