Skip to content

Commit

Permalink
Improve MediaStream guards
Browse files Browse the repository at this point in the history
  • Loading branch information
seniorapple committed Jun 4, 2018
1 parent d2303e3 commit 010fec7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/players/FilePlayer.js
@@ -1,6 +1,6 @@
import React, { Component } from 'react'

import { getSDK } from '../utils'
import { getSDK, isMediaStream } from '../utils'
import createSinglePlayer from '../singlePlayer'

const IOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream
Expand All @@ -14,10 +14,6 @@ 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 Down
8 changes: 8 additions & 0 deletions src/utils.js
Expand Up @@ -161,3 +161,11 @@ export function isEqual (a, b) {
}
return a === b
}

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

0 comments on commit 010fec7

Please sign in to comment.