From eccf6561e8cd1e9e6a609fe0b2f8fb2be08fd7fe Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Wed, 26 Oct 2022 19:13:10 +0300 Subject: [PATCH] fix cleanup of detection timeout --- src/apiClient.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/apiClient.js b/src/apiClient.js index 4b0e1f3..3d32349 100644 --- a/src/apiClient.js +++ b/src/apiClient.js @@ -18,11 +18,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(); } @@ -31,6 +33,7 @@ function redetectBitrateInternal() { function stopBitrateDetection(instance) { if (instance.detectTimeout) { clearTimeout(instance.detectTimeout); + instance.detectTimeout = null; } }