Skip to content

Commit

Permalink
fix: Reject TS content on Edge
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Feb 28, 2023
1 parent 2d0e4cc commit a643487
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/polyfill/mediasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ shaka.polyfill.MediaSource = class {
// Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342
shaka.polyfill.MediaSource.stubAbort_();
}
} else if (shaka.util.Platform.isEdge()) {
// TS content is broken on Edge in general.
// See https://github.com/shaka-project/shaka-player/issues/4955
shaka.polyfill.MediaSource.rejectTsContent_();
} else if (shaka.util.Platform.isTizen2() ||
shaka.util.Platform.isTizen3() ||
shaka.util.Platform.isTizen4()) {
Expand Down Expand Up @@ -122,6 +126,29 @@ shaka.polyfill.MediaSource = class {
};
}

/**
* Patch isTypeSupported() to reject TS content. Used to avoid TS-related MSE
* bugs on Edge.
*
* @private
*/
static rejectTsContent_() {
const originalIsTypeSupported = MediaSource.isTypeSupported;

MediaSource.isTypeSupported = (mimeType) => {
// Parse the basic MIME type from its parameters.
const pieces = mimeType.split(/ *; */);
const basicMimeType = pieces[0];
const container = basicMimeType.split('/')[1];

if (container.toLowerCase() == 'mp2t') {
return false;
}

return originalIsTypeSupported(mimeType);
};
}

/**
* Patch |MediaSource.isTypeSupported| to always reject |codec|. This is used
* when we know that we are on a platform that does not work well with a given
Expand Down

0 comments on commit a643487

Please sign in to comment.