From 850cda2ae36556b581dfa03e7ac90dc838431ac3 Mon Sep 17 00:00:00 2001 From: Undyingwraith Date: Thu, 24 Oct 2024 10:25:01 +0200 Subject: [PATCH] Update Indexer --- .../src/Services/Indexer/MovieIndexFetcher.ts | 5 +- .../Services/Indexer/SeriesIndexFetcher.ts | 2 +- packages/ui/package.json | 2 +- .../src/components/organisms/VideoPlayer.tsx | 51 ++++++++++++++----- yarn.lock | 14 ++--- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/packages/core/src/Services/Indexer/MovieIndexFetcher.ts b/packages/core/src/Services/Indexer/MovieIndexFetcher.ts index 2ea4f83..ce356ef 100644 --- a/packages/core/src/Services/Indexer/MovieIndexFetcher.ts +++ b/packages/core/src/Services/Indexer/MovieIndexFetcher.ts @@ -20,11 +20,12 @@ export class MovieIndexFetcher implements IIndexFetcher { public async extractMovieMetaData(node: IIpfsService, entry: IFileInfo, skeleton?: any): Promise { const files = (await this.node.ls(entry.cid)).filter(f => f.type == 'file'); + const videoFile = files.filter(f => f.name.endsWith('.mpd'))[0]; return { ...entry, - title: entry.name, - video: files.filter(f => f.name.endsWith('.mp4'))[0], + title: videoFile.name.substring(0, videoFile.name.lastIndexOf('.')), + video: videoFile, thumbnails: files.filter(f => Regexes.Thumbnail.exec(f.name) != null), posters: files.filter(f => Regexes.Poster.exec(f.name) != null), }; diff --git a/packages/core/src/Services/Indexer/SeriesIndexFetcher.ts b/packages/core/src/Services/Indexer/SeriesIndexFetcher.ts index c39e532..47bf536 100644 --- a/packages/core/src/Services/Indexer/SeriesIndexFetcher.ts +++ b/packages/core/src/Services/Indexer/SeriesIndexFetcher.ts @@ -62,7 +62,7 @@ export class SeriesIndexFetcher implements IIndexFetcher { ...entry, posters: files.filter(f => Regexes.Poster.exec(f.name) != null), title: entry.name, - video: files.filter(f => f.name.endsWith('.mp4'))[0], + video: files.filter(f => f.name.endsWith('.mpd'))[0], thumbnails: files.filter(f => Regexes.Thumbnail.exec(f.name) != null), }; diff --git a/packages/ui/package.json b/packages/ui/package.json index b1be8f8..a7e3cb3 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -48,7 +48,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-i18next": "^14.1.1", - "shaka-player": "^3.3.2", + "shaka-player": "^4.11.8", "wouter": "^3.2.0" } } diff --git a/packages/ui/src/components/organisms/VideoPlayer.tsx b/packages/ui/src/components/organisms/VideoPlayer.tsx index 44cc7e5..e583eca 100644 --- a/packages/ui/src/components/organisms/VideoPlayer.tsx +++ b/packages/ui/src/components/organisms/VideoPlayer.tsx @@ -1,4 +1,4 @@ -import { useSignal, useSignalEffect } from '@preact/signals-react'; +import { useComputed, useSignal, useSignalEffect } from '@preact/signals-react'; import { IIpfsService, IIpfsServiceSymbol, IVideoFile } from 'ipmc-interfaces'; import React from 'react'; import { useService } from '../../context'; @@ -13,7 +13,6 @@ function createShakaIpfsPlugin(ipfs: IIpfsService): shaka.extern.SchemePlugin { const cid = paths.shift()!; const path = paths.join('/'); - console.log(uri, fullPath, path, cid, request, requestType, config); headersReceived({}); const data = await ipfs.fetch(cid, path); @@ -31,6 +30,8 @@ export function VideoPlayer(props: { file: IVideoFile; }) { const ipfs = useService(IIpfsServiceSymbol); const videoRef = useSignal(null); const playerRef = useSignal(null); + const subtitles = useSignal([]); + const languages = useSignal([]); useHotkey({ key: 'F' }, () => { videoRef.value?.requestFullscreen(); @@ -42,10 +43,10 @@ export function VideoPlayer(props: { file: IVideoFile; }) { const player = new shaka.Player(); playerRef.value = player; player.attach(videoRef.value) - .then(() => player.load(`ipfs://QmediiYR5uAswBjrDGXFhR2BHk9j9Fe3v7tZbfeF3Qe4oa/video.mpd`)) - //.then(() => player.load(`ipfs://${props.file.cid}/${props.file.video.name}`)) + .then(() => player.load(`ipfs://${props.file.cid}/${props.file.video.name}`)) .then(() => { - console.log('player ready'); + subtitles.value = player.getTextTracks(); + languages.value = player.getAudioLanguages(); }) .catch((ex: any) => { console.error(ex); @@ -61,14 +62,36 @@ export function VideoPlayer(props: { file: IVideoFile; }) { }); return ( - +
+ + Language + + Subtitle + +
); } diff --git a/yarn.lock b/yarn.lock index 8564ba8..b069aca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5513,7 +5513,7 @@ __metadata: languageName: node linkType: hard -"eme-encryption-scheme-polyfill@npm:^2.1.1": +"eme-encryption-scheme-polyfill@npm:^2.1.5": version: 2.1.5 resolution: "eme-encryption-scheme-polyfill@npm:2.1.5" checksum: 10c0/14fbba1beb91293abf2703901be3026b0270466c5048d24ea2b6d486b61d8dc255518fdfff41e2012e8dc9c7897bc542c22b3fcadc6ee89e58bb05fc9d4fda34 @@ -7476,7 +7476,7 @@ __metadata: react: "npm:^18.3.1" react-dom: "npm:^18.3.1" react-i18next: "npm:^14.1.1" - shaka-player: "npm:^3.3.2" + shaka-player: "npm:^4.11.8" terser: "npm:^5.31.0" typescript: "npm:^5.4.5" vite: "npm:^5.2.11" @@ -10748,12 +10748,12 @@ __metadata: languageName: node linkType: hard -"shaka-player@npm:^3.3.2": - version: 3.3.19 - resolution: "shaka-player@npm:3.3.19" +"shaka-player@npm:^4.11.8": + version: 4.11.8 + resolution: "shaka-player@npm:4.11.8" dependencies: - eme-encryption-scheme-polyfill: "npm:^2.1.1" - checksum: 10c0/5dc8a5bb12cfe00207e1c0da24fddbc78b6b4fa62640c88e4ac04d5abde5bc63d61ace963fa440990d620a022c3cdd2ad5a376434bbbd545b3f77e63086de9fc + eme-encryption-scheme-polyfill: "npm:^2.1.5" + checksum: 10c0/58ae27475d81537d575b4525b1360b2f3c32bdd3944f7dda82949e5e09cfc5ae39719a15355adb4f30208ac2898c1a39eac52c059b96acd3d8d4f3855d2c9c6f languageName: node linkType: hard