From e4f00e62aca4f9e1b293f3a62f48048d73bb1394 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Tue, 23 Jun 2026 10:29:58 +0200 Subject: [PATCH] fix: refactor Windows detection for PlayReady DRM compatibility --- src/utils/playready-workaround.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/utils/playready-workaround.ts b/src/utils/playready-workaround.ts index d90a080d8e0..71bd61ad48e 100644 --- a/src/utils/playready-workaround.ts +++ b/src/utils/playready-workaround.ts @@ -19,6 +19,17 @@ import { } from './mp4-tools'; import type { LevelDetails } from '../loader/level-details'; +function isWindows(): boolean { + const uaData = (navigator as { userAgentData?: { platform?: string } }) + .userAgentData; + if (uaData?.platform) { + return uaData.platform.toLowerCase() === 'windows'; + } + return ( + !!navigator.platform && navigator.platform.toLowerCase().includes('win') + ); +} + /** * Applies a PlayReady DRM workaround to level details. * @@ -168,7 +179,7 @@ export function fakeEncryption(initSegment: Uint8Array) { // not clear why this is necessary on Xbox One, but it seems to be evidence // of another bug in the firmware implementation of MediaSource & EME. // TODO: needs more tests - if (navigator.userAgent.match(/Edge?\//)) { + if (isWindows()) { newEntries.push(encEntry); newEntries.push(entry); } else { @@ -266,7 +277,7 @@ export function fakeEncryption(initSegment: Uint8Array) { // patched one, otherwise video element throws following error: // CHUNK_DEMUXER_ERROR_APPEND_FAILED: Sample encryption info is not // available. - if (navigator.userAgent.match(/Edge?\//)) { + if (isWindows()) { return appendUint8Array(modifiedInitSegment, initSegment); } else { return modifiedInitSegment;