diff --git a/src/components/VideoPlayer/SubtitleManager.tsx b/src/components/VideoPlayer/SubtitleManager.tsx
index ca636f2..62f9c12 100644
--- a/src/components/VideoPlayer/SubtitleManager.tsx
+++ b/src/components/VideoPlayer/SubtitleManager.tsx
@@ -1,7 +1,11 @@
-import React, { useCallback, useEffect, useState } from "react";
-import { QortalGetMetadata, QortalMetadata, Service } from "../../types/interfaces/resources";
+import React, { useCallback, useEffect, useRef, useState } from "react";
import {
- alpha,
+ QortalGetMetadata,
+ QortalMetadata,
+ Service,
+} from "../../types/interfaces/resources";
+import {
+ alpha,
Box,
Button,
ButtonBase,
@@ -15,8 +19,10 @@ import {
Popover,
Typography,
} from "@mui/material";
-import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos';
-import ModeEditIcon from '@mui/icons-material/ModeEdit';
+import CheckIcon from '@mui/icons-material/Check';
+import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
+import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
+import ModeEditIcon from "@mui/icons-material/ModeEdit";
import CloseIcon from "@mui/icons-material/Close";
import { useListStore } from "../../state/lists";
import { Resource, useResources } from "../../hooks/useResources";
@@ -31,14 +37,15 @@ import {
} from "react-dropzone";
import { fileToBase64, objectToBase64 } from "../../utils/base64";
import { ResourceToPublish } from "../../types/qortalRequests/types";
-import { useListReturn } from "../../hooks/useListData";
+import { useListReturn } from "../../hooks/useListData";
import { usePublish } from "../../hooks/usePublish";
interface SubtitleManagerProps {
qortalMetadata: QortalGetMetadata;
close: () => void;
open: boolean;
- onSelect: (subtitle: SubtitlePublishedData)=> void;
- subtitleBtnRef: any
+ onSelect: (subtitle: SubtitlePublishedData) => void;
+ subtitleBtnRef: any;
+ currentSubTrack: null | string;
}
export interface Subtitle {
language: string | null;
@@ -65,32 +72,38 @@ const SubtitleManagerComponent = ({
open,
close,
onSelect,
- subtitleBtnRef
+ subtitleBtnRef,
+ currentSubTrack,
}: SubtitleManagerProps) => {
const [mode, setMode] = useState(1);
const { lists, identifierOperations, auth } = useGlobal();
const { fetchResources } = useResources();
// const [subtitles, setSubtitles] = useState([])
- const subtitles = useListReturn(`subs-${qortalMetadata?.service}-${qortalMetadata?.name}-${qortalMetadata?.identifier}`)
-
+ const subtitles = useListReturn(
+ `subs-${qortalMetadata?.service}-${qortalMetadata?.name}-${qortalMetadata?.identifier}`
+ );
- console.log('subtitles222', subtitles)
+ console.log("subtitles222", subtitles);
const getPublishedSubtitles = useCallback(async () => {
try {
const videoId = `${qortalMetadata?.service}-${qortalMetadata?.name}-${qortalMetadata?.identifier}`;
- console.log('videoId', videoId)
+ console.log("videoId", videoId);
const postIdSearch = await identifierOperations.buildSearchPrefix(
ENTITY_SUBTITLE,
- videoId,
+ videoId
);
const searchParams = {
service: SERVICE_SUBTITLE,
identifier: postIdSearch,
- limit: 0
+ limit: 0,
};
- const res = await lists.fetchResources(searchParams, `subs-${videoId}`, "BASE64");
- lists.addList(`subs-${videoId}`, res || []);
- console.log('resres2', res)
+ const res = await lists.fetchResources(
+ searchParams,
+ `subs-${videoId}`,
+ "BASE64"
+ );
+ lists.addList(`subs-${videoId}`, res || []);
+ console.log("resres2", res);
} catch (error) {
console.error(error);
}
@@ -104,7 +117,7 @@ const SubtitleManagerComponent = ({
)
return;
- getPublishedSubtitles()
+ getPublishedSubtitles();
}, [
qortalMetadata?.identifier,
qortalMetadata?.service,
@@ -120,137 +133,153 @@ const SubtitleManagerComponent = ({
// setHasMetadata(false);
};
-
const publishHandler = async (subtitles: Subtitle[]) => {
try {
- const videoId = `${qortalMetadata?.service}-${qortalMetadata?.name}-${qortalMetadata?.identifier}`;
+ const videoId = `${qortalMetadata?.service}-${qortalMetadata?.name}-${qortalMetadata?.identifier}`;
- const identifier = await identifierOperations.buildIdentifier(ENTITY_SUBTITLE, videoId);
- const name = auth?.name
-console.log('identifier2', identifier)
- if(!name) return
- const resources: ResourceToPublish[] = []
- const tempResources: {qortalMetadata: QortalMetadata, data: any}[] = []
- for(const sub of subtitles ){
- const data = {
- subtitleData: sub.base64,
- language: sub.language,
- filename: sub.filename,
- type: sub.type
- }
-
- const base64Data = await objectToBase64(data)
- const resource = {
- name,
- identifier,
- service: SERVICE_SUBTITLE,
- base64: base64Data,
- filename: sub.filename,
- title: sub.language || undefined
- }
- resources.push(resource)
- tempResources.push({
- qortalMetadata: {
- identifier,
- service: SERVICE_SUBTITLE,
- name,
- size: 100,
- created: Date.now()
- },
- data: data,
- })
- }
- console.log('resources', resources)
+ const identifier = await identifierOperations.buildIdentifier(
+ ENTITY_SUBTITLE,
+ videoId
+ );
+ const name = auth?.name;
+ console.log("identifier2", identifier);
+ if (!name) return;
+ const resources: ResourceToPublish[] = [];
+ const tempResources: { qortalMetadata: QortalMetadata; data: any }[] = [];
+ for (const sub of subtitles) {
+ const data = {
+ subtitleData: sub.base64,
+ language: sub.language,
+ filename: sub.filename,
+ type: sub.type,
+ };
- await qortalRequest({
- action: 'PUBLISH_MULTIPLE_QDN_RESOURCES',
- resources
- })
+ const base64Data = await objectToBase64(data);
+ const resource = {
+ name,
+ identifier,
+ service: SERVICE_SUBTITLE,
+ base64: base64Data,
+ filename: sub.filename,
+ title: sub.language || undefined,
+ };
+ resources.push(resource);
+ tempResources.push({
+ qortalMetadata: {
+ identifier,
+ service: SERVICE_SUBTITLE,
+ name,
+ size: 100,
+ created: Date.now(),
+ },
+ data: data,
+ });
+ }
+ console.log("resources", resources);
-
- lists.addNewResources(`subs-${qortalMetadata?.service}-${qortalMetadata?.name}-${qortalMetadata?.identifier}`, tempResources)
- } catch (error) {
-
- }
+ await qortalRequest({
+ action: "PUBLISH_MULTIPLE_QDN_RESOURCES",
+ resources,
+ });
+
+ lists.addNewResources(
+ `subs-${qortalMetadata?.service}-${qortalMetadata?.name}-${qortalMetadata?.identifier}`,
+ tempResources
+ );
+ } catch (error) {}
+ };
+ const onBack = () => {
+ if (mode === 1) close();
+ };
+
+ const onSelectHandler = (sub: SubtitlePublishedData) => {
+ console.log('onSelectHandler')
+ onSelect(sub);
+ close();
};
- const onBack = ()=> {
- if(mode === 1) close()
- }
- const onSelectHandler = (sub: SubtitlePublishedData)=> {
- onSelect(sub)
- close()
- }
return (
+
-
-
-
-
-
- Subtitles
-
-
-
-
-
-
-
- {mode === 1 && (
+
+
+
+
+
+ Subtitles
+
+
+
+
+
+
+
+ {mode === 1 && (
)}
- {/*
+ {/*
{[
'Ambient mode',
'Annotations',
@@ -274,7 +303,7 @@ console.log('identifier2', identifier)
))}
*/}
-
+
//