Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/utils/playready-workaround.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
Loading