Skip to content

Commit

Permalink
fix: don't use navigator.connection event listener if it isn't implem…
Browse files Browse the repository at this point in the history
…ented (#5157)

Fixes #4542
  • Loading branch information
cristian-atehortua authored and joeyparrish committed Apr 26, 2023
1 parent 6f695d2 commit 7d8b867
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/abr/simple_abr_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7d8b867

Please sign in to comment.