Fix global vars

This commit is contained in:
redphx
2024-04-24 16:50:59 +07:00
parent 9446e39eb0
commit 9d0f4c380b
30 changed files with 87 additions and 69 deletions

View File

@@ -1,6 +1,7 @@
import { t } from "../translation";
import { BxEvent } from "../bx-event";
import { CE } from "../../utils/html";
import { States } from "../../utils/global";
enum StreamBadge {
PLAYTIME = 'playtime',
@@ -85,7 +86,7 @@ export class StreamBadges {
} catch(e) {}
}
const stats = await STREAM_WEBRTC.getStats();
const stats = await States.currentStream.peerConnection?.getStats()!;
let totalIn = 0;
let totalOut = 0;
stats.forEach(stat => {

View File

@@ -1,9 +1,10 @@
import { PrefKey, Preferences } from "../preferences"
import { PrefKey } from "../preferences"
import { BxEvent } from "../bx-event"
import { getPref } from "../preferences"
import { StreamBadges } from "./stream-badges"
import { CE } from "../../utils/html"
import { t } from "../translation"
import { States } from "../../utils/global"
export enum StreamStat {
PING = 'ping',
@@ -105,13 +106,13 @@ export class StreamStats {
}
static update() {
if (StreamStats.isHidden() || !STREAM_WEBRTC) {
if (StreamStats.isHidden() || !States.currentStream.peerConnection) {
StreamStats.onStoppedPlaying();
return;
}
const PREF_STATS_CONDITIONAL_FORMATTING = getPref(PrefKey.STATS_CONDITIONAL_FORMATTING);
STREAM_WEBRTC.getStats().then(stats => {
States.currentStream.peerConnection.getStats().then(stats => {
stats.forEach(stat => {
let grade = '';
if (stat.type === 'inbound-rtp' && stat.kind === 'video') {
@@ -213,7 +214,7 @@ export class StreamStats {
}
static getServerStats() {
STREAM_WEBRTC && STREAM_WEBRTC.getStats().then(stats => {
States.currentStream.peerConnection && States.currentStream.peerConnection.getStats().then(stats => {
const allVideoCodecs: {[index: string]: RTCBasicStat} = {};
let videoCodecId;

View File

@@ -1,3 +1,4 @@
import { States } from "../../utils/global";
import { Icon } from "../../utils/html";
import { BxEvent } from "../bx-event";
import { PrefKey, getPref } from "../preferences";
@@ -44,6 +45,7 @@ class MouseHoldEvent {
this.#$elm.addEventListener('touchend', this.#onMouseUp.bind(this));
}
/*
#clearEventLiseners = () => {
this.#$elm.removeEventListener('mousedown', this.#onMouseDown);
this.#$elm.removeEventListener('click', this.#onMouseUp);
@@ -51,6 +53,7 @@ class MouseHoldEvent {
this.#$elm.removeEventListener('touchstart', this.#onMouseDown);
this.#$elm.removeEventListener('touchend', this.#onMouseUp);
}
*/
constructor($elm: HTMLElement, callback: any, duration=1000) {
this.#$elm = $elm;