Continued tweaking of latency compensation

This commit is contained in:
Gabe Kangas
2022-03-19 13:17:37 -07:00
parent d3aa3f87af
commit d96ddcc6c6
2 changed files with 59 additions and 24 deletions

View File

@@ -236,28 +236,35 @@ class OwncastPlayer {
this.appPlayerPlayingCallback();
}
setInterval(() => {
const tech = this.vjsPlayer.tech({ IWillNotUseThisInPlugins: true });
const bandwidth = tech.vhs.systemBandwidth;
this.playbackMetrics.trackBandwidth(bandwidth);
this.latencyCompensator.enable();
try {
const segment = getCurrentlyPlayingSegment(tech);
const segmentTime = segment.dateTimeObject.getTime();
const now = new Date().getTime();
const latency = now - segmentTime;
this.playbackMetrics.trackLatency(latency);
} catch (err) {
console.warn(err);
}
setInterval(() => {
this.collectPlaybackMetrics();
}, 5000);
}
collectPlaybackMetrics() {
const tech = this.vjsPlayer.tech({ IWillNotUseThisInPlugins: true });
const bandwidth = tech.vhs.systemBandwidth;
this.playbackMetrics.trackBandwidth(bandwidth);
try {
const segment = getCurrentlyPlayingSegment(tech);
const segmentTime = segment.dateTimeObject.getTime();
const now = new Date().getTime();
const latency = now - segmentTime;
this.playbackMetrics.trackLatency(latency);
} catch (err) {
console.warn(err);
}
}
handleEnded() {
this.log('on Ended');
if (this.appPlayerEndedCallback) {
this.appPlayerEndedCallback();
}
this.latencyCompensator.disable();
}
handleError(e) {