Skip to content

Commit

Permalink
Update Indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
undyingwraith committed Oct 24, 2024
1 parent ef50f9c commit 850cda2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 25 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/Services/Indexer/MovieIndexFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ export class MovieIndexFetcher implements IIndexFetcher<IMovieMetaData[]> {

public async extractMovieMetaData(node: IIpfsService, entry: IFileInfo, skeleton?: any): Promise<IMovieMetaData> {
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),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Services/Indexer/SeriesIndexFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class SeriesIndexFetcher implements IIndexFetcher<ISeriesMetaData[]> {
...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),
};

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
51 changes: 37 additions & 14 deletions packages/ui/src/components/organisms/VideoPlayer.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand All @@ -31,6 +30,8 @@ export function VideoPlayer(props: { file: IVideoFile; }) {
const ipfs = useService<IIpfsService>(IIpfsServiceSymbol);
const videoRef = useSignal<HTMLVideoElement | null>(null);
const playerRef = useSignal<any | null>(null);
const subtitles = useSignal<any[]>([]);
const languages = useSignal<string[]>([]);

useHotkey({ key: 'F' }, () => {
videoRef.value?.requestFullscreen();
Expand All @@ -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);
Expand All @@ -61,14 +62,36 @@ export function VideoPlayer(props: { file: IVideoFile; }) {
});

return (
<video
controls
style={{ height: '85vh', maxWidth: '100%', maxHeight: '100%' }}
ref={(ref) => {
videoRef.value = ref;
}}
preload={'metadata'}
>
</video>
<div>
<video
controls
style={{ height: '85vh', maxWidth: '100%', maxHeight: '100%' }}
ref={(ref) => {
videoRef.value = ref;
}}
preload={'metadata'}
>
</video>
Language
<select>
{useComputed(() => languages.value.map(l => (
<option>{l}</option>
)))}
</select>
Subtitle
<select onChange={(ev) => {
if (ev.currentTarget.value !== 'null') {
playerRef.value.selectTextTrack(ev.currentTarget.value);
playerRef.value.setTextTrackVisibility(true);
} else {
playerRef.value.setTextTrackVisibility(false);
}
}}>
<option value="null">None</option>
{useComputed(() => subtitles.value.map(l => (
<option>{l.language}</option>
)))}
</select>
</div>
);
}
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 850cda2

Please sign in to comment.