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

fix: excessive requests when using HDCP fallback with LDL #225

Merged
merged 15 commits into from
Aug 27, 2024
Merged
4 changes: 2 additions & 2 deletions src/eme.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ export const makeNewRequest = (player, requestOptions) => {
keySession
});

player.on('dispose', () => {
player.on(['dispose', 'ended'], () => {
keySession.close().then(() => {
safeTriggerOnEventBus(eventBus, {
type: 'keysessionclosed',
keySession
});
removeSession(initData);
}).catch((error) => {
const metadata = {
errorType: EmeError.EMEFailedToCloseSession,
Expand Down Expand Up @@ -245,7 +246,6 @@ export const makeNewRequest = (player, requestOptions) => {
keySession
});
removeSession(initData);
makeNewRequest(player, requestOptions);
}).catch((error) => {
const metadata = {
errorType: EmeError.EMEFailedToCloseSession,
Expand Down
12 changes: 12 additions & 0 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,21 @@ const eme = function(options = {}) {
const player = this;

const emeError = emeErrorHandler(player);
let contentHasEnded = false;

player.ready(() => onPlayerReady(player, emeError));

player.on('ended', () =>{
contentHasEnded = true;

player.one('play', () => {
if (contentHasEnded && player.currentTime() === 0) {
contentHasEnded = true;
Essk marked this conversation as resolved.
Show resolved Hide resolved
onPlayerReady(player, emeError);
}
});
});

// Plugin API
player.eme = {
/**
Expand Down
2 changes: 0 additions & 2 deletions test/eme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ QUnit.test('keystatuseschange with expired key closes and recreates session', fu
// synchronously
assert.equal(removeSessionCalls.length, 1, 'called remove session');
assert.equal(removeSessionCalls[0], initData, 'called to remove session with initData');

assert.equal(creates, 2, 'created another session');
});

QUnit.test('keystatuseschange with internal-error logs a warning', function(assert) {
Expand Down
Loading