Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Track buffering events as errors differently in playback metrics

Gabe Kangasb175c8a675c0
diff --git a/webroot/js/components/player.js b/webroot/js/components/player.js
index bdfc1dabb8..5031d3a1ee 100644
--- a/webroot/js/components/player.js
+++ b/webroot/js/components/player.js
@@ -238,7 +238,7 @@ class OwncastPlayer {
const latency = now - segmentTime;
this.playbackMetrics.trackLatency(latency);
} catch (err) {
- console.warn(err);
+ // console.warn(err);
}
}
@@ -261,12 +261,12 @@ class OwncastPlayer {
}
handleWaiting(e) {
- // this.playbackMetrics.incrementErrorCount(1);
- this.playbackMetrics.isBuffering = true;
+ this.playbackMetrics.incrementErrorCount(1);
+ this.playbackMetrics.setIsBuffering(true);
}
handleNoLongerBuffering() {
- this.playbackMetrics.isBuffering = false;
+ this.playbackMetrics.setIsBuffering(false);
}
log(message) {
diff --git a/webroot/js/metrics/playback.js b/webroot/js/metrics/playback.js
index b468a8594d..5bb530dc97 100644
--- a/webroot/js/metrics/playback.js
+++ b/webroot/js/metrics/playback.js
@@ -11,6 +11,7 @@ class PlaybackMetrics {
this.errors = 0;
this.qualityVariantChanges = 0;
this.isBuffering = false;
+ this.bufferingDurationTimer = 0;
setInterval(() => {
this.send();
@@ -31,6 +32,19 @@ class PlaybackMetrics {
this.qualityVariantChanges++;
}
+ setIsBuffering(isBuffering) {
+ this.isBuffering = isBuffering;
+
+ if (!isBuffering) {
+ clearTimeout(this.bufferingDurationTimer);
+ return;
+ }
+
+ this.bufferingDurationTimer = setTimeout(() => {
+ this.incrementErrorCount(1);
+ }, 500);
+ }
+
trackSegmentDownloadTime(seconds) {
this.segmentDownloadTime.push(seconds);
}