diff --git a/src/components/admin/ContentRendererClient.tsx b/src/components/admin/ContentRendererClient.tsx index 3dd40d353..e6a4be66b 100644 --- a/src/components/admin/ContentRendererClient.tsx +++ b/src/components/admin/ContentRendererClient.tsx @@ -3,7 +3,7 @@ import { useSearchParams, useRouter } from 'next/navigation'; // import { QualitySelector } from '../QualitySelector'; import { VideoPlayerSegment } from '@/components/VideoPlayerSegment'; import VideoContentChapters from '../VideoContentChapters'; -import { useState } from 'react'; +import { useMemo, useState } from 'react'; import { handleMarkAsCompleted } from '@/lib/utils'; export const ContentRendererClient = ({ @@ -47,31 +47,28 @@ export const ContentRendererClient = ({ } const mpdUrl = metadata?.[quality || '1080'] || ''; - let source = {}; - if (mpdUrl.endsWith('.mpd')) { - //@ts-ignore - source = { - src: mpdUrl, - type: 'application/dash+xml', - keySystems: { - 'com.widevine.alpha': - 'https://widevine-dash.ezdrm.com/proxy?pX=288FF5&user_id=MTAwMA==', - }, - }; - } else if (mpdUrl.endsWith('.m3u8')) { - //@ts-ignore - source = { - src: mpdUrl, - type: 'application/x-mpegURL', - }; - } else { - //@ts-ignore - source = { + const source = useMemo(() => { + if (mpdUrl.endsWith('.mpd')) { + return { + src: mpdUrl, + type: 'application/dash+xml', + keySystems: { + 'com.widevine.alpha': + 'https://widevine-dash.ezdrm.com/proxy?pX=288FF5&user_id=MTAwMA==', + }, + }; + } else if (mpdUrl.endsWith('.m3u8')) { + return { + src: mpdUrl, + type: 'application/x-mpegURL', + }; + } + return { src: mpdUrl, type: 'video/mp4', }; - } + }, [mpdUrl]); const toggleShowChapters = () => { setShowChapters((prev) => !prev);