diff --git a/CHANGELOG_CN.md b/CHANGELOG_CN.md index 98e95fe7a..fd6dbee03 100644 --- a/CHANGELOG_CN.md +++ b/CHANGELOG_CN.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - 使用 `switchUrl` 或者 `switchQuality` 方法切换地址后会保持原有的调整如:`aspectRatio`, `playbackRate`, `flip`, `autoSize` - 删除 `switchUrl` 方法和 `switchQuality` 方法的第二个 `name` 参数 +- 添加 `isIOS13` 工具,用于修复在 `IOS13` 以上版本的设备上的 `isMobile` 判断不准确的问题 ## [5.0.6] - 2023-5-3 diff --git a/packages/artplayer/src/utils/compatibility.js b/packages/artplayer/src/utils/compatibility.js index a9ed0e9eb..144023e92 100644 --- a/packages/artplayer/src/utils/compatibility.js +++ b/packages/artplayer/src/utils/compatibility.js @@ -1,7 +1,8 @@ -export const userAgent = typeof window !== 'undefined' ? window.navigator.userAgent : ''; -export const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent); +export const userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : ''; export const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent); export const isWechat = /MicroMessenger/i.test(userAgent); export const isIE = /MSIE|Trident/i.test(userAgent); export const isAndroid = /android/i.test(userAgent); export const isIOS = /iPad|iPhone|iPod/i.test(userAgent) && !window.MSStream; +export const isIOS13 = isIOS || (userAgent.includes('Macintosh') && navigator.maxTouchPoints >= 1); +export const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent) || isIOS13; diff --git a/packages/artplayer/types/utils.d.ts b/packages/artplayer/types/utils.d.ts index eea02f181..32173dfdd 100644 --- a/packages/artplayer/types/utils.d.ts +++ b/packages/artplayer/types/utils.d.ts @@ -6,6 +6,7 @@ export type Utils = { isIE: boolean; isAndroid: boolean; isIOS: boolean; + isIOS13: boolean; query(selector: string, parent?: HTMLElement): HTMLElement; queryAll(selector: string, parent?: HTMLElement): HTMLElement[]; addClass(target: HTMLElement, className: string): void;