Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider ManagedSourceBuffer in MSE support detection #6846

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
9 changes: 7 additions & 2 deletions src/is-supported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Comment on lines +5 to +6
Copy link
Collaborator

@robwalch robwalch Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only place getSourceBuffer is called is in this module by isMSESupported. Adding the preferManagedSourceBuffer argument is unnecessary, as it is never passed in. That argument is used by player instances calling getMediaSource and not the static method isMSESupported used to check for the presence of MSE or compatible Managed Media Source.

): 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;
Comment on lines +5 to +11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be willing to merge with the following change. See previous comment for reasoning:

Suggested change
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;
function getSourceBuffer(): typeof self.SourceBuffer {
return self.SourceBuffer || (self as any).ManagedSourceBuffer || (self as any).WebKitSourceBuffer;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niklaskorz would you be willing to make the requested changes?

}

export function isMSESupported(): boolean {
Expand Down
Loading