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

Validate the existence of MediaSource before check MediaSource.isTypeSupported in MediaCapabilities polyfill #3225

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 4 additions & 2 deletions lib/polyfill/media_capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ shaka.polyfill.MediaCapabilities = class {
// Use 'MediaSource.isTypeSupported' to check if the stream is supported.
if (mediaDecodingConfig['video']) {
const contentType = mediaDecodingConfig['video'].contentType;
const isSupported = MediaSource.isTypeSupported(contentType);
const isSupported =
window.MediaSource && MediaSource.isTypeSupported(contentType);
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. Could this occur on iOS, since there's no MediaSource there?

Although this would fix an exception being thrown when MediaSource is not available, your solution would call all content unsupported on such a platform. Why would that be okay?

if (!isSupported) {
return Promise.resolve(res);
}
}

if (mediaDecodingConfig['audio']) {
const contentType = mediaDecodingConfig['audio'].contentType;
const isSupported = MediaSource.isTypeSupported(contentType);
const isSupported =
window.MediaSource && MediaSource.isTypeSupported(contentType);
if (!isSupported) {
return Promise.resolve(res);
}
Expand Down