fix: don't use navigator.connection event listener if it isn't implemented (#5157)

Fixes #4542
This commit is contained in:
Cristian Atehortua
2023-04-18 15:22:26 -05:00
committed by GitHub
parent 9c4a61f836
commit fb6830693c
+2 -2
View File
@@ -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;