mirror of
https://github.com/video-dev/hls.js.git
synced 2026-06-16 13:34:44 +00:00
Fix licenseXhrSetup return types and selectKeySystem nested Promise anti-pattern
This commit is contained in:
@@ -1301,7 +1301,7 @@ export class EMEController extends Logger implements ComponentAPI {
|
||||
export type EMEControllerConfig = {
|
||||
licenseXhrSetup?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext & {
|
||||
decryptdata: LevelKey;
|
||||
}, licenseChallenge: Uint8Array) => void | Uint8Array | Promise<Uint8Array | void>;
|
||||
}, licenseChallenge: Uint8Array) => void | Uint8Array | string | Promise<Uint8Array | string | void>;
|
||||
licenseResponseCallback?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext & {
|
||||
decryptdata: LevelKey;
|
||||
}) => ArrayBuffer;
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ export type EMEControllerConfig = {
|
||||
url: string,
|
||||
keyContext: MediaKeySessionContext & { decryptdata: LevelKey },
|
||||
licenseChallenge: Uint8Array,
|
||||
) => void | Uint8Array | Promise<Uint8Array | void>;
|
||||
) => void | Uint8Array | string | Promise<Uint8Array | string | void>;
|
||||
licenseResponseCallback?: (
|
||||
this: Hls,
|
||||
xhr: XMLHttpRequest,
|
||||
|
||||
@@ -428,20 +428,17 @@ class EMEController extends Logger implements ComponentAPI {
|
||||
private selectKeySystem(
|
||||
keySystemsToAttempt: KeySystems[],
|
||||
): Promise<KeySystemFormats> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.getKeySystemSelectionPromise(keySystemsToAttempt)
|
||||
.then(({ keySystem }) => {
|
||||
const keySystemFormat = keySystemDomainToKeySystemFormat(keySystem);
|
||||
if (keySystemFormat) {
|
||||
resolve(keySystemFormat);
|
||||
} else {
|
||||
reject(
|
||||
new Error(`Unable to find format for key-system "${keySystem}"`),
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
return this.getKeySystemSelectionPromise(keySystemsToAttempt).then(
|
||||
({ keySystem }) => {
|
||||
const keySystemFormat = keySystemDomainToKeySystemFormat(keySystem);
|
||||
if (!keySystemFormat) {
|
||||
throw new Error(
|
||||
`Unable to find format for key-system "${keySystem}"`,
|
||||
);
|
||||
}
|
||||
return keySystemFormat;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public selectKeySystemFormat(frag: Fragment): Promise<KeySystemFormats> {
|
||||
|
||||
Reference in New Issue
Block a user