Skip to content

Commit

Permalink
fix cleanup of detection timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylyzo committed Oct 26, 2022
1 parent 2cf202f commit e87d51f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ function redetectBitrate(instance) {
stopBitrateDetection(instance);

if (instance.accessToken() && instance.enableAutomaticBitrateDetection !== false) {
setTimeout(redetectBitrateInternal.bind(instance), 6000);
instance.detectTimeout = setTimeout(redetectBitrateInternal.bind(instance), 6000);
}
}

function redetectBitrateInternal() {
this.detectTimeout = null;

if (this.accessToken()) {
this.detectBitrate();
}
Expand All @@ -29,6 +31,7 @@ function redetectBitrateInternal() {
function stopBitrateDetection(instance) {
if (instance.detectTimeout) {
clearTimeout(instance.detectTimeout);
instance.detectTimeout = null;
}
}

Expand Down

0 comments on commit e87d51f

Please sign in to comment.