({
metadata,
content,
nextContent,
}: {
nextContent: {
id: number;
type: string;
title: string;
} | null;
metadata: any;
content: {
type: 'video' | 'appx';
id: number;
title: string;
thumbnail: string;
description: string;
markAsCompleted: boolean;
appxVideoId?: string;
appxCourseId?: string;
};
})
| 8 | import Link from 'next/link'; |
| 9 | |
| 10 | export const ContentRendererClient = ({ |
| 11 | metadata, |
| 12 | content, |
| 13 | nextContent, |
| 14 | }: { |
| 15 | nextContent: { |
| 16 | id: number; |
| 17 | type: string; |
| 18 | title: string; |
| 19 | } | null; |
| 20 | metadata: any; |
| 21 | content: { |
| 22 | type: 'video' | 'appx'; |
| 23 | id: number; |
| 24 | title: string; |
| 25 | thumbnail: string; |
| 26 | description: string; |
| 27 | markAsCompleted: boolean; |
| 28 | appxVideoId?: string; |
| 29 | appxCourseId?: string; |
| 30 | }; |
| 31 | }) => { |
| 32 | const [showChapters, setShowChapters] = useState( |
| 33 | metadata?.segments?.length > 0, |
| 34 | ); |
| 35 | const searchParams = useSearchParams(); |
| 36 | |
| 37 | const router = useRouter(); |
| 38 | |
| 39 | //@ts-ignore |
| 40 | const [quality, setQuality] = useState<string>( |
| 41 | searchParams.get('quality') ?? '1080', |
| 42 | ); |
| 43 | |
| 44 | if (!metadata) { |
| 45 | return <div>Loading</div>; |
| 46 | } |
| 47 | |
| 48 | const mpdUrl = metadata?.[quality || '1080'] || ''; |
| 49 | |
| 50 | const source = useMemo(() => { |
| 51 | if (mpdUrl.endsWith('.mpd')) { |
| 52 | return { |
| 53 | src: mpdUrl, |
| 54 | type: 'application/dash+xml', |
| 55 | keySystems: { |
| 56 | 'com.widevine.alpha': |
| 57 | 'https://widevine-dash.ezdrm.com/proxy?pX=288FF5&user_id=MTAwMA==', |
| 58 | }, |
| 59 | }; |
| 60 | } else if (mpdUrl.endsWith('.m3u8')) { |
| 61 | return { |
| 62 | src: mpdUrl, |
| 63 | type: 'application/x-mpegURL', |
| 64 | }; |
| 65 | } |
| 66 | return { |
| 67 | src: mpdUrl, |
nothing calls this directly
no test coverage detected