optional stats to fix birdseye player

This commit is contained in:
Josh Hawkins 2024-12-28 11:37:49 -06:00
parent 0a9bf413f6
commit 14acca3a01
3 changed files with 12 additions and 12 deletions

View File

@ -14,7 +14,7 @@ type JSMpegPlayerProps = {
containerRef: React.MutableRefObject<HTMLDivElement | null>;
playbackEnabled: boolean;
useWebGL: boolean;
setStats: (stats: PlayerStatsType) => void;
setStats?: (stats: PlayerStatsType) => void;
onPlaying?: () => void;
};
@ -166,7 +166,7 @@ export default function JSMpegPlayer({
const timeDiff = (currentTimestamp - lastTimestampRef.current) / 1000; // in seconds
const bitrate = (bytesReceivedRef.current * 8) / timeDiff / 1000; // in kbps
setStats({
setStats?.({
streamType: "jsmpeg",
bandwidth: Math.round(bitrate),
totalFrames: frameCount,

View File

@ -22,8 +22,8 @@ type MSEPlayerProps = {
volume?: number;
playInBackground?: boolean;
pip?: boolean;
getStats: boolean;
setStats: (stats: PlayerStatsType) => void;
getStats?: boolean;
setStats?: (stats: PlayerStatsType) => void;
onPlaying?: () => void;
setFullResolution?: React.Dispatch<SetStateAction<VideoResolutionType>>;
onError?: (error: LivePlayerError) => void;
@ -37,7 +37,7 @@ function MSEPlayer({
volume,
playInBackground = false,
pip = false,
getStats,
getStats = false,
setStats,
onPlaying,
setFullResolution,
@ -611,7 +611,7 @@ function MSEPlayer({
? (droppedVideoFrames / totalVideoFrames) * 100
: 0;
setStats({
setStats?.({
streamType: "MSE",
bandwidth,
latency,
@ -627,7 +627,7 @@ function MSEPlayer({
return () => {
clearInterval(interval);
setStats({
setStats?.({
streamType: "-",
bandwidth: 0,
latency: undefined,

View File

@ -11,8 +11,8 @@ type WebRtcPlayerProps = {
microphoneEnabled?: boolean;
iOSCompatFullScreen?: boolean; // ios doesn't support fullscreen divs so we must support the video element
pip?: boolean;
getStats: boolean;
setStats: (stats: PlayerStatsType) => void;
getStats?: boolean;
setStats?: (stats: PlayerStatsType) => void;
onPlaying?: () => void;
onError?: (error: LivePlayerError) => void;
};
@ -26,7 +26,7 @@ export default function WebRtcPlayer({
microphoneEnabled = false,
iOSCompatFullScreen = false,
pip = false,
getStats,
getStats = false,
setStats,
onPlaying,
onError,
@ -268,7 +268,7 @@ export default function WebRtcPlayer({
? (bytesReceived - lastBytesReceived) / timeDiff / 1000
: 0; // in kbps
setStats({
setStats?.({
streamType: "WebRTC",
bandwidth: Math.round(bitrate),
latency: roundTripTime,
@ -286,7 +286,7 @@ export default function WebRtcPlayer({
return () => {
clearInterval(interval);
setStats({
setStats?.({
streamType: "-",
bandwidth: 0,
latency: undefined,