Skip to content

Commit

Permalink
Merge pull request #2490 from video-dev/bugfix/source-buffer-exception
Browse files Browse the repository at this point in the history
Fix `isSupported` check in browsers missing `SourceBuffer` global
  • Loading branch information
robwalch committed Jan 6, 2020
2 parents 908507f + e81a953 commit 3b16e49
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 66 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Expand Up @@ -76,6 +76,13 @@ module.exports = {
'never'
],

'no-restricted-globals': [2,
{
'name': 'SourceBuffer',
'message': 'Use `self.SourceBuffer`'
}
],

'no-restricted-properties': [2,
{ 'property': 'findIndex' }, // Intended to block usage of Array.prototype.findIndex
{ 'property': 'find' } // Intended to block usage of Array.prototype.find
Expand Down
145 changes: 81 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -80,7 +80,7 @@
"selenium-webdriver": "^3.1.0",
"sinon": "7.1.1",
"sinon-chai": "3.3.0",
"typescript": "^3.3.1",
"typescript": "^3.7.4",
"typescript-eslint-parser": "^21.0.2",
"webpack": "^4.27.1",
"webpack-cli": "^3.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/is-supported.ts
Expand Up @@ -5,7 +5,7 @@ export function isSupported (): boolean {
if (!mediaSource) {
return false;
}
const sourceBuffer = SourceBuffer || (window as any).WebKitSourceBuffer;
const sourceBuffer = self.SourceBuffer || (self as any).WebKitSourceBuffer as SourceBuffer;
const isTypeSupported = mediaSource &&
typeof mediaSource.isTypeSupported === 'function' &&
mediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"');
Expand Down

0 comments on commit 3b16e49

Please sign in to comment.