Skip to content

Commit

Permalink
Merge pull request #1515 from canalplus/fix/titan-os-media-keys
Browse files Browse the repository at this point in the history
DRM: Re-create MediaKeys for each content on Philips' NETTV
  • Loading branch information
peaBerberian authored Aug 30, 2024
2 parents e9f9758 + d51b338 commit c2bf43b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
35 changes: 33 additions & 2 deletions src/compat/__tests__/can_reuse_media_keys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe("Compat - canReuseMediaKeys", () => {
vi.resetModules();
});

it("should return true on any browser but WebOS", async () => {
it("should return true on most browsers", async () => {
vi.doMock("../browser_detection", () => {
return { isWebOs: false, isPanasonic: false };
return { isWebOs: false, isPhilipsNetTv: false, isPanasonic: false };
});
const canReuseMediaKeys = (await vi.importActual(
"../can_reuse_media_keys.ts",
Expand All @@ -26,6 +26,37 @@ describe("Compat - canReuseMediaKeys", () => {
isWebOs: true,
isWebOs2022: false,
isPanasonic: false,
isPhilipsNetTv: false,
};
});
const canReuseMediaKeys = (await vi.importActual(
"../can_reuse_media_keys.ts",
)) as any;
expect(canReuseMediaKeys.default()).toBe(false);
});

it("should return false on Panasonic", async () => {
vi.doMock("../browser_detection", () => {
return {
isWebOs: false,
isWebOs2022: false,
isPanasonic: true,
isPhilipsNetTv: false,
};
});
const canReuseMediaKeys = (await vi.importActual(
"../can_reuse_media_keys.ts",
)) as any;
expect(canReuseMediaKeys.default()).toBe(false);
});

it("should return false on Philips' NETTV", async () => {
vi.doMock("../browser_detection", () => {
return {
isWebOs: false,
isWebOs2022: false,
isPanasonic: false,
isPhilipsNetTv: true,
};
});
const canReuseMediaKeys = (await vi.importActual(
Expand Down
9 changes: 9 additions & 0 deletions src/compat/browser_detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ let isWebOs2022 = false;
/** `true` for Panasonic devices. */
let isPanasonic = false;

/** `true` we're relying on Philips's NetTv browser. */
let isPhilipsNetTv = false;

/** `true` for the PlayStation 4 game console. */
let isPlayStation4 = false;

Expand Down Expand Up @@ -155,6 +158,11 @@ let isXbox = false;
) {
isWebOs2021 = true;
}
} else if (
navigator.userAgent.indexOf("NETTV") !== -1 &&
navigator.userAgent.indexOf("Philips") !== -1
) {
isPhilipsNetTv = true;
} else if (/[Pp]anasonic/.test(navigator.userAgent)) {
isPanasonic = true;
} else if (navigator.userAgent.indexOf("Xbox") !== -1) {
Expand All @@ -168,6 +176,7 @@ export {
isIEOrEdge,
isFirefox,
isPanasonic,
isPhilipsNetTv,
isPlayStation4,
isPlayStation5,
isXbox,
Expand Down
6 changes: 4 additions & 2 deletions src/compat/can_reuse_media_keys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPanasonic, isWebOs } from "./browser_detection";
import { isPanasonic, isPhilipsNetTv, isWebOs } from "./browser_detection";

/**
* Returns `true` if a `MediaKeys` instance (the `Encrypted Media Extension`
Expand All @@ -9,9 +9,11 @@ import { isPanasonic, isWebOs } from "./browser_detection";
* - (2022-11-21): WebOS (LG TVs), for some encrypted contents, just
* rebuffered indefinitely when loading a content already-loaded on the
* HTMLMediaElement.
* - (2024-08-23): Seen on Philips 2024 and 2023 in:
* https://github.com/canalplus/rx-player/issues/1464
*
* @returns {boolean}
*/
export default function canReuseMediaKeys(): boolean {
return !isWebOs && !isPanasonic;
return !isWebOs && !isPhilipsNetTv && !isPanasonic;
}

0 comments on commit c2bf43b

Please sign in to comment.