Skip to content

Commit

Permalink
Fix iPad Pro detection
Browse files Browse the repository at this point in the history
  • Loading branch information
webmiraclepro committed Sep 7, 2020
1 parent 298146f commit 185d5be
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import React, { Component } from 'react'
import { getSDK, isMediaStream, supportsWebKitPresentationMode } from '../utils'
import { canPlay, AUDIO_EXTENSIONS, HLS_EXTENSIONS, DASH_EXTENSIONS, FLV_EXTENSIONS } from '../patterns'

const IOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream
const HAS_NAVIGATOR = typeof navigator !== 'undefined'
const IS_IPAD_PRO = HAS_NAVIGATOR && navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1
const IS_IOS = HAS_NAVIGATOR && (/iPad|iPhone|iPod/.test(navigator.userAgent) || IS_IPAD_PRO) && !window.MSStream
const HLS_SDK_URL = 'https://cdn.jsdelivr.net/npm/hls.js@VERSION/dist/hls.min.js'
const HLS_GLOBAL = 'Hls'
const DASH_SDK_URL = 'https://cdnjs.cloudflare.com/ajax/libs/dashjs/VERSION/dash.all.min.js'
Expand All @@ -21,7 +23,7 @@ export default class FilePlayer extends Component {
componentDidMount () {
this.props.onMount && this.props.onMount(this)
this.addListeners(this.player)
if (IOS) {
if (IS_IOS) {
this.player.load()
}
}
Expand Down Expand Up @@ -121,7 +123,7 @@ export default class FilePlayer extends Component {
if (this.props.config.forceHLS) {
return true
}
if (IOS) {
if (IS_IOS) {
return false
}
return HLS_EXTENSIONS.test(url) || MATCH_CLOUDFLARE_STREAM.test(url)
Expand Down

0 comments on commit 185d5be

Please sign in to comment.