From 2da19d96bebbc5730336fa97a154f812225edfe8 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Sat, 6 Jan 2024 13:58:18 +0900 Subject: [PATCH] wip --- .../frontend/src/components/MkMediaVideo.vue | 385 ++++++++++++++---- packages/frontend/src/filters/hms.ts | 27 ++ packages/frontend/src/scripts/device-kind.ts | 7 + 3 files changed, 343 insertions(+), 76 deletions(-) create mode 100644 packages/frontend/src/filters/hms.ts diff --git a/packages/frontend/src/components/MkMediaVideo.vue b/packages/frontend/src/components/MkMediaVideo.vue index f9dba0b15a..6376e47b22 100644 --- a/packages/frontend/src/components/MkMediaVideo.vue +++ b/packages/frontend/src/components/MkMediaVideo.vue @@ -4,39 +4,70 @@ SPDX-License-Identifier: AGPL-3.0-only --> diff --git a/packages/frontend/src/filters/hms.ts b/packages/frontend/src/filters/hms.ts new file mode 100644 index 0000000000..0885f4118c --- /dev/null +++ b/packages/frontend/src/filters/hms.ts @@ -0,0 +1,27 @@ +export default (ms: number) => { + const res: string[] = []; + + // ミリ秒を秒に変換 + let seconds = Math.floor(ms / 1000); + + // 時間を計算 + let hours = Math.floor(seconds / 3600); + if (hours > 0) res.push(format(hours)); + seconds %= 3600; + + // 分を計算 + let minutes = Math.floor(seconds / 60); + res.push(format(minutes)); + seconds %= 60; + + // 残った秒数を取得 + seconds = seconds % 60; + res.push(format(seconds)); + + // 結果を返す + return res.join(':'); +}; + +function format(n: number) { + return n.toString().padStart(2, '0'); +} diff --git a/packages/frontend/src/scripts/device-kind.ts b/packages/frontend/src/scripts/device-kind.ts index 3843052a24..218eb718b1 100644 --- a/packages/frontend/src/scripts/device-kind.ts +++ b/packages/frontend/src/scripts/device-kind.ts @@ -11,6 +11,13 @@ const ua = navigator.userAgent.toLowerCase(); const isTablet = /ipad/.test(ua) || (/mobile|iphone|android/.test(ua) && window.innerWidth > 700); const isSmartphone = !isTablet && /mobile|iphone|android/.test(ua); +const isIPhone = /iphone|ipod/gi.test(ua) && navigator.maxTouchPoints > 1; +// navigator.platform may be deprecated but this check is still required +const isIPadOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1; +const isIos = /ipad|iphone|ipod/gi.test(ua) && navigator.maxTouchPoints > 1; + +export const isFullscreenNotSupported = isIPhone || isIos; + export const deviceKind: 'smartphone' | 'tablet' | 'desktop' = defaultStore.state.overridedDeviceKind ? defaultStore.state.overridedDeviceKind : isSmartphone ? 'smartphone' : isTablet ? 'tablet'