Replace IS_IOS and IS_ANDROID with platform
This commit is contained in:
parent
c4d11c6c48
commit
49db1fe83b
3 changed files with 10 additions and 18 deletions
|
@ -23,6 +23,7 @@ import recsys from './plugins/videojs-recsys/plugin';
|
|||
// import runAds from './ads';
|
||||
import videojs from 'video.js';
|
||||
import { useIsMobile } from 'effects/use-screensize';
|
||||
import { platform } from 'util/platform';
|
||||
|
||||
const canAutoplay = require('./plugins/canAutoplay');
|
||||
|
||||
|
@ -98,12 +99,7 @@ type Props = {
|
|||
};
|
||||
|
||||
const videoPlaybackRates = [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 1.75, 2];
|
||||
|
||||
const IS_IOS =
|
||||
(/iPad|iPhone|iPod/.test(navigator.platform) ||
|
||||
// for iOS 13+ , platform is MacIntel, so use this to test
|
||||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&
|
||||
!window.MSStream;
|
||||
const IS_IOS = platform.isIOS();
|
||||
|
||||
if (!Object.keys(videojs.getPlugins()).includes('eventTracking')) {
|
||||
videojs.registerPlugin('eventTracking', eventTracking);
|
||||
|
|
|
@ -167,7 +167,12 @@ export const platform = {
|
|||
// **************************************************************************
|
||||
|
||||
isIOS: function () {
|
||||
return this.userAgent().match(/iPhone|iPad|iPod/i) != null;
|
||||
return (
|
||||
(/iPad|iPhone|iPod/.test(navigator.platform) ||
|
||||
// for iOS 13+ , platform is MacIntel, so use this to test
|
||||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&
|
||||
!window.MSStream
|
||||
);
|
||||
},
|
||||
|
||||
isAndroid: function () {
|
||||
|
|
|
@ -5,6 +5,7 @@ import React, { useEffect } from 'react';
|
|||
import I18nMessage from 'component/i18nMessage';
|
||||
import Button from 'component/button';
|
||||
import classnames from 'classnames';
|
||||
import { platform } from 'util/platform';
|
||||
|
||||
// prettier-ignore
|
||||
const AD_CONFIGS = Object.freeze({
|
||||
|
@ -22,16 +23,6 @@ const AD_CONFIGS = Object.freeze({
|
|||
},
|
||||
});
|
||||
|
||||
const IS_IOS =
|
||||
(/iPad|iPhone|iPod/.test(navigator.platform) ||
|
||||
// for iOS 13+ , platform is MacIntel, so use this to test
|
||||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&
|
||||
!window.MSStream;
|
||||
const IS_ANDROID = /Android/i.test(navigator.userAgent);
|
||||
// const IS_FIREFOX = /Firefox/i.test(navigator.userAgent);
|
||||
|
||||
// const isFirefoxAndroid = IS_ANDROID && IS_FIREFOX;
|
||||
|
||||
// Internal use only. One-time update flag.
|
||||
let ad_blocker_detected;
|
||||
|
||||
|
@ -55,7 +46,7 @@ function Ads(props: Props) {
|
|||
const { type = 'video', tileLayout, small, userHasPremiumPlus, className, doSetAdBlockerFound } = props;
|
||||
|
||||
const [shouldShowAds, setShouldShowAds] = React.useState(resolveAdVisibility());
|
||||
const mobileAds = IS_ANDROID || IS_IOS;
|
||||
const mobileAds = platform.isAndroid() || platform.isIOS();
|
||||
|
||||
// this is populated from app based on location
|
||||
const isInEu = localStorage.getItem('gdprRequired') === 'true';
|
||||
|
|
Loading…
Reference in a new issue