Skip to content

Commit a4b3ce7

Browse files
committed
[v3] Add A1 KSTB 40XX to our list of devices which cannot reuse MediaKeys
This is a backport of #1530 for the v3
1 parent 4356cd3 commit a4b3ce7

3 files changed

Lines changed: 39 additions & 7 deletions

File tree

src/compat/__tests__/can_reuse_media_keys.test.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ describe("Compat - canReuseMediaKeys", () => {
1212
jest.mock("../browser_detection", () => {
1313
return {
1414
__esModule: true as const,
15+
isA1KStb40xx: false,
1516
isWebOs: false,
1617
isPhilipsNetTv: false,
1718
isPanasonic: false,
1819
};
1920
});
20-
const canReuseMediaKeys =
21-
jest.requireActual("../can_reuse_media_keys.ts");
21+
const canReuseMediaKeys = jest.requireActual("../can_reuse_media_keys.ts");
2222
expect(canReuseMediaKeys.default()).toBe(true);
2323
});
2424

2525
it("should return false on WebOs", () => {
2626
jest.mock("../browser_detection", () => {
2727
return {
2828
__esModule: true as const,
29+
isA1KStb40xx: false,
2930
isWebOs: true,
3031
isWebOs2022: false,
3132
isPanasonic: false,
@@ -40,6 +41,7 @@ describe("Compat - canReuseMediaKeys", () => {
4041
jest.mock("../browser_detection", () => {
4142
return {
4243
__esModule: true as const,
44+
isA1KStb40xx: false,
4345
isWebOs: false,
4446
isWebOs2022: false,
4547
isPanasonic: true,
@@ -54,6 +56,7 @@ describe("Compat - canReuseMediaKeys", () => {
5456
jest.mock("../browser_detection", () => {
5557
return {
5658
__esModule: true as const,
59+
isA1KStb40xx: false,
5760
isWebOs: false,
5861
isWebOs2022: false,
5962
isPanasonic: false,
@@ -63,4 +66,19 @@ describe("Compat - canReuseMediaKeys", () => {
6366
const canReuseMediaKeys = jest.requireActual("../can_reuse_media_keys.ts");
6467
expect(canReuseMediaKeys.default()).toBe(false);
6568
});
69+
70+
it("should return false on A1 KSTB 40xxx", () => {
71+
jest.mock("../browser_detection", () => {
72+
return {
73+
__esModule: true as const,
74+
isA1KStb40xx: true,
75+
isWebOs: false,
76+
isWebOs2022: false,
77+
isPanasonic: false,
78+
isPhilipsNetTv: false,
79+
};
80+
});
81+
const canReuseMediaKeys = jest.requireActual("../can_reuse_media_keys.ts");
82+
expect(canReuseMediaKeys.default()).toBe(false);
83+
});
6684
});

src/compat/browser_detection.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ let isPlayStation5 = false;
6969
/** `true` for the Xbox game consoles. */
7070
let isXbox = false;
7171

72+
/** `true` for specific A1 STB: KSTB 40xx from Kaon Media. */
73+
let isA1KStb40xx = false;
74+
7275
((function findCurrentBrowser() : void {
7376
if (isNode) {
7477
return ;
@@ -155,6 +158,8 @@ let isXbox = false;
155158
isPanasonic = true;
156159
} else if (navigator.userAgent.indexOf("Xbox") !== -1) {
157160
isXbox = true;
161+
} else if (navigator.userAgent.indexOf("Model/a1-kstb40xx")) {
162+
isA1KStb40xx = true;
158163
}
159164
})());
160165

@@ -163,19 +168,23 @@ interface ISafariWindowObject extends Window {
163168
}
164169

165170
export {
171+
// browsers
166172
isEdgeChromium,
173+
isFirefox,
167174
isIE11,
168175
isIEOrEdge,
169-
isFirefox,
176+
isSafariDesktop,
177+
isSafariMobile,
178+
179+
// specific devices
180+
isA1KStb40xx,
170181
isPanasonic,
171182
isPhilipsNetTv,
172183
isPlayStation5,
173-
isXbox,
174-
isSafariDesktop,
175-
isSafariMobile,
176184
isSamsungBrowser,
177185
isTizen,
178186
isWebOs,
179187
isWebOs2021,
180188
isWebOs2022,
189+
isXbox,
181190
};

src/compat/can_reuse_media_keys.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
isA1KStb40xx,
23
isPanasonic,
34
isPhilipsNetTv,
45
isWebOs,
@@ -15,9 +16,13 @@ import {
1516
* HTMLMediaElement.
1617
* - (2024-08-23): Seen on Philips 2024 and 2023 in:
1718
* https://github.com/canalplus/rx-player/issues/1464
19+
* - (2024-09-04): Another case seen on an "A1" set-top box model made by
20+
* Kaonmedia we will call the KSTB40xx.
21+
* It may share the problematic with other devices, but we have only seen
22+
* the problem on this one for now.
1823
*
1924
* @returns {boolean}
2025
*/
2126
export default function canReuseMediaKeys(): boolean {
22-
return !isWebOs && !isPhilipsNetTv && !isPanasonic;
27+
return !isWebOs && !isPhilipsNetTv && !isPanasonic && !isA1KStb40xx;
2328
}

0 commit comments

Comments
 (0)