From 6dfdc5916593eca1fe253a0c87f23a8767907635 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 24 Jul 2024 07:23:26 +0000 Subject: [PATCH] fix: replace videojs with plyr --- .../components/cell/attachment/Carousel.vue | 4 +- .../cell/attachment/Preview/Video.vue | 85 +++---------------- packages/nc-gui/utils/objectUtils.ts | 26 ------ 3 files changed, 16 insertions(+), 99 deletions(-) delete mode 100644 packages/nc-gui/utils/objectUtils.ts diff --git a/packages/nc-gui/components/cell/attachment/Carousel.vue b/packages/nc-gui/components/cell/attachment/Carousel.vue index 81626027b4..f2e67fda37 100644 --- a/packages/nc-gui/components/cell/attachment/Carousel.vue +++ b/packages/nc-gui/components/cell/attachment/Carousel.vue @@ -144,8 +144,8 @@ watchOnce(emblaMainApi, async (emblaMainApi) => { -import videojs from 'video.js' -import { stripUndefinedOrNull } from '~/utils/objectUtils' -import 'video.js/dist/video-js.css' +import Plyr from 'plyr' +import 'plyr/dist/plyr.css' interface Props { - autoplay?: boolean - controls?: boolean - height?: string | number - loop?: boolean - muted?: boolean - poster?: string - preload?: 'auto' | 'metadata' | 'none' - width?: string | number - aspectRatio?: string - audioOnlyMode?: boolean - audioPosterMode?: boolean - autoSetup?: boolean - disablePictureInPicture?: boolean - enableDocumentPictireInPicture?: boolean - enableSmoothSeeking?: boolean - fluid?: boolean - src?: string - fullScreen?: { - options?: { - navigationUI?: 'hide' | 'show' - id?: string - } - } - inactivityTimeout?: number - language?: string - liveui?: boolean - notSupportedMessage?: string - playbackRates?: number[] - playsinline?: boolean - plugins?: Record - preferFullWindow?: boolean - responsive?: boolean - restoreEl?: Element | boolean - skipButtons?: { - forward?: number - back?: number - } - sources?: { - src: string - type: string - }[] - suppressNotSupportedError?: boolean - techOrder?: string[] - userActions?: { - click?: (event: Event) => void | boolean - doubleClick?: (event: Event) => void | boolean - hotkeys?: (event: Event) => void | boolean | Record void> - } + src?: string[] + mimeType?: string class?: string } const props = withDefaults(defineProps(), { - preload: 'metadata', - controls: true, - audioOnlyMode: false, - audioPosterMode: false, - autoSetup: true, - disablePictureInPicture: false, - enableDocumentPictireInPicture: false, - enableSmoothSeeking: true, - fluid: true, - language: 'en', - liveui: true, - playsinline: true, - preferFullWindow: false, - responsive: true, - restoreEl: false, class: '', }) @@ -80,19 +18,19 @@ interface Emits { (event: 'init', player: any): void } -const videoPlayer = ref() +const videoPlayer = ref() const player = ref() onMounted(() => { if (!videoPlayer.value) return - player.value = videojs(videoPlayer.value, stripUndefinedOrNull(props)) + player.value = new Plyr(videoPlayer.value) emit('init', player.value) }) onBeforeUnmount(() => { if (player.value) { - player.value.dispose() + player.value.destroy() } }) @@ -100,11 +38,16 @@ onBeforeUnmount(() => { diff --git a/packages/nc-gui/utils/objectUtils.ts b/packages/nc-gui/utils/objectUtils.ts deleted file mode 100644 index 6eb34de220..0000000000 --- a/packages/nc-gui/utils/objectUtils.ts +++ /dev/null @@ -1,26 +0,0 @@ -type NonUndefined = T extends undefined ? never : T -type NonNull = T extends null ? never : T -type NonNullableObject = { - [K in keyof T]: NonUndefined> -} - -type Prettify = { - [K in keyof T]: T[K] -} & {} - -export const stripUndefinedOrNull = (obj: T): Prettify> => { - const strip = (input: unknown): unknown => { - return Array.isArray(input) - ? input.map(strip) - : input !== null && typeof input === 'object' - ? Object.entries(input) - .filter(([, value]) => value !== undefined && value !== null) - .reduce((acc, [key, value]) => { - acc[key as keyof typeof acc] = strip(value) - return acc - }, {} as Record) - : input - } - - return strip(obj) as Prettify> -}