Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent key errors from being emitted twice #6704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/controller/eme-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ class EMEController extends Logger implements ComponentAPI {
'encrypted-event-key-match',
);
});
keySessionContextPromise.catch((error) => this.handleError(error));
break;
}
}
Expand Down Expand Up @@ -671,8 +672,8 @@ class EMEController extends Logger implements ComponentAPI {
});
},
);
keySessionContextPromise.catch((error) => this.handleError(error));
}
keySessionContextPromise.catch((error) => this.handleError(error));
};

private onWaitingForKey = (event: Event) => {
Expand Down Expand Up @@ -768,8 +769,11 @@ class EMEController extends Logger implements ComponentAPI {
messageType === 'license-renewal'
) {
this.renewLicense(context, message).catch((error) => {
this.handleError(error);
licenseStatus.emit('error', error);
if (licenseStatus.eventNames().length) {
licenseStatus.emit('error', error);
} else {
this.handleError(error);
}
});
} else if (messageType === 'license-release') {
if (context.keySystem === KeySystems.FAIRPLAY) {
Expand Down Expand Up @@ -1230,6 +1234,8 @@ class EMEController extends Logger implements ComponentAPI {
// keep reference of media
this.media = media;

media.removeEventListener('encrypted', this.onMediaEncrypted);
media.removeEventListener('waitingforkey', this.onWaitingForKey);
media.addEventListener('encrypted', this.onMediaEncrypted);
media.addEventListener('waitingforkey', this.onWaitingForKey);
}
Expand Down
Loading