From 3e77cb55fb8d1e46a25795443d8dee2ed1953df0 Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Fri, 15 Nov 2024 09:55:01 +0100 Subject: [PATCH] Consider ManagedSourceBuffer in MSE support detection --- src/is-supported.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/is-supported.ts b/src/is-supported.ts index bbf3b3214f2..d5e59845c42 100644 --- a/src/is-supported.ts +++ b/src/is-supported.ts @@ -2,8 +2,13 @@ import { mimeTypeForCodec } from './utils/codecs'; import { getMediaSource } from './utils/mediasource-helper'; import type { ExtendedSourceBuffer } from './types/buffer'; -function getSourceBuffer(): typeof self.SourceBuffer { - return self.SourceBuffer || (self as any).WebKitSourceBuffer; +function getSourceBuffer( + preferManagedSourceBuffer = true, +): typeof self.SourceBuffer { + const msb = + (preferManagedSourceBuffer || !self.SourceBuffer) && + ((self as any).ManagedSourceBuffer as undefined | typeof self.SourceBuffer); + return msb || self.SourceBuffer || (self as any).WebKitSourceBuffer; } export function isMSESupported(): boolean {