Skip to content

Commit

Permalink
feat: eme error interface
Browse files Browse the repository at this point in the history
  • Loading branch information
adrums86 committed Feb 27, 2024
1 parent db802f5 commit bae0cba
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export const emeErrorHandler = (player) => {
}

player.error(error);
player.eme.error({
errorType: videojs.Error.EMEKeySessionCreationError,
error
});
};
};

Expand Down Expand Up @@ -404,7 +408,27 @@ const eme = function(options = {}) {
});
},
detectSupportedCDMs,
options
options,
_error: null,
error(err) {

// If `err` doesn't exist, return the current error.
if (err === undefined) {
return this._error || null;
}

// If `err` is null, reset the ads error.
if (err === null) {
this._error = null;

return;
}

this._error = err;

videojs.log.error(`EME error occured of type: ${err.errorType}.`);
player.trigger('vjsemeerror');
}
};
};

Expand Down
6 changes: 6 additions & 0 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,12 @@ QUnit.test('emeError properly handles various parameter types', function(assert)
},
error: (obj) => {
errorObj = obj;
},
eme: {
_error: null,
error: (err) => {
this._error = err;
}
}
};
const emeError = emeErrorHandler(player);
Expand Down

0 comments on commit bae0cba

Please sign in to comment.