style: format static/player/hls_profile.ts

This commit is contained in:
2026-06-21 02:04:40 +02:00
committed by Milas Holsting
parent 9054f43a11
commit 967c897300

View File

@@ -1,7 +1,8 @@
import Hls from "hls.js";
import type { ErrorData } from "hls.js"; import type { ErrorData } from "hls.js";
interface HLSPlaybackProfile { import Hls from "hls.js";
type HLSPlaybackProfile = {
sourceLoads: number; sourceLoads: number;
manifestParsed: number; manifestParsed: number;
stalls: number; stalls: number;
@@ -11,7 +12,7 @@ interface HLSPlaybackProfile {
errors: number; errors: number;
fatalErrors: number; fatalErrors: number;
lastErrorType: string; lastErrorType: string;
} };
declare global { declare global {
interface Window { interface Window {
@@ -70,14 +71,18 @@ export const attachHLSProfile = (hls: Hls, video: HTMLVideoElement): (() => void
}; };
const onWaiting = (): void => { const onWaiting = (): void => {
if (stallStartedAt !== null) return; if (stallStartedAt !== null) {
return;
}
stallStartedAt = performance.now(); stallStartedAt = performance.now();
profile.stalls += 1; profile.stalls += 1;
mark("stall_start"); mark("stall_start");
}; };
const onPlaying = (): void => { const onPlaying = (): void => {
if (stallStartedAt === null) return; if (stallStartedAt === null) {
return;
}
profile.totalStallMs += performance.now() - stallStartedAt; profile.totalStallMs += performance.now() - stallStartedAt;
stallStartedAt = null; stallStartedAt = null;
measure("stall", "stall_start"); measure("stall", "stall_start");
@@ -89,7 +94,9 @@ export const attachHLSProfile = (hls: Hls, video: HTMLVideoElement): (() => void
}; };
const onSeeked = (): void => { const onSeeked = (): void => {
if (seekStartedAt === null) return; if (seekStartedAt === null) {
return;
}
profile.seeks += 1; profile.seeks += 1;
profile.totalSeekMs += performance.now() - seekStartedAt; profile.totalSeekMs += performance.now() - seekStartedAt;
seekStartedAt = null; seekStartedAt = null;