Skip to content

Commit

Permalink
Remove requirement for window global
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed May 30, 2018
1 parent 4bd78e0 commit 9618272
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const DASH_SDK_URL = 'https://cdnjs.cloudflare.com/ajax/libs/dashjs/2.6.5/dash.a
const DASH_GLOBAL = 'dashjs'
const MATCH_DROPBOX_URL = /www\.dropbox\.com\/.+/

function isMediaStream (url) {
return typeof window !== 'undefined' && url instanceof window.MediaStream
}

function canPlay (url) {
if (url instanceof Array) {
for (let item of url) {
Expand All @@ -26,7 +30,7 @@ function canPlay (url) {
}
return false
}
if (url instanceof window.MediaStream) {
if (isMediaStream(url)) {
return true
}
return (
Expand Down Expand Up @@ -118,7 +122,7 @@ export class FilePlayer extends Component {
this.dash.getDebug().setLogToBrowserConsole(false)
})
}
if (url instanceof window.MediaStream) {
if (isMediaStream(url)) {
try {
this.player.srcObject = url
} catch (e) {
Expand Down Expand Up @@ -180,7 +184,7 @@ export class FilePlayer extends Component {
getSource (url) {
const useHLS = this.shouldUseHLS(url)
const useDASH = this.shouldUseDASH(url)
if (url instanceof Array || url instanceof window.MediaStream || useHLS || useDASH) {
if (url instanceof Array || isMediaStream(url) || useHLS || useDASH) {
return undefined
}
if (MATCH_DROPBOX_URL.test(url)) {
Expand Down

0 comments on commit 9618272

Please sign in to comment.