From fb6830693ca0dcde709d1b000dfacd4e6c05ec7b Mon Sep 17 00:00:00 2001 From: Cristian Atehortua <48300727+cristian-atehortua@users.noreply.github.com> Date: Tue, 18 Apr 2023 15:22:26 -0500 Subject: [PATCH] fix: don't use navigator.connection event listener if it isn't implemented (#5157) Fixes #4542 --- lib/abr/simple_abr_manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/abr/simple_abr_manager.js b/lib/abr/simple_abr_manager.js index 1029333055..304d11eec2 100644 --- a/lib/abr/simple_abr_manager.js +++ b/lib/abr/simple_abr_manager.js @@ -52,7 +52,7 @@ shaka.abr.SimpleAbrManager = class { // retrieving information about a user's network connection. We listen // to the change event to be able to make quick changes in case the type // of connectivity changes. - if (navigator.connection) { + if (navigator.connection && navigator.connection.addEventListener) { this.onNetworkInformationChange_ = () => { if (this.config_.useNetworkInformation && this.enabled_) { this.bandwidthEstimator_ = new shaka.abr.EwmaBandwidthEstimator(); @@ -143,7 +143,7 @@ shaka.abr.SimpleAbrManager = class { release() { // stop() should already have been called for unload - if (navigator.connection) { + if (navigator.connection && navigator.connection.removeEventListener) { navigator.connection.removeEventListener( 'change', this.onNetworkInformationChange_); this.onNetworkInformationChange_ = null;