mirror of
https://github.com/Qortal/q-tube.git
synced 2025-02-14 19:25:52 +00:00
Publishing is done with base64 instead of file
fixed bug that could sometimes prevent video from playing after it is paused
This commit is contained in:
parent
6412417891
commit
0551db5d22
@ -338,7 +338,7 @@ export const EditPlaylist = () => {
|
|||||||
action: "PUBLISH_QDN_RESOURCE",
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
name: username,
|
name: username,
|
||||||
service: "PLAYLIST",
|
service: "PLAYLIST",
|
||||||
file: objectToFile(playlistObject),
|
data64: await objectToBase64(playlistObject),
|
||||||
title: title.slice(0, 50),
|
title: title.slice(0, 50),
|
||||||
description: metadescription,
|
description: metadescription,
|
||||||
identifier: identifier,
|
identifier: identifier,
|
||||||
|
@ -304,7 +304,7 @@ export const EditVideo = () => {
|
|||||||
action: "PUBLISH_QDN_RESOURCE",
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
name: username,
|
name: username,
|
||||||
service: "DOCUMENT",
|
service: "DOCUMENT",
|
||||||
file: objectToFile(videoObject),
|
data64: await objectToBase64(videoObject),
|
||||||
title: title.slice(0, 50),
|
title: title.slice(0, 50),
|
||||||
description: metadescription,
|
description: metadescription,
|
||||||
identifier: editVideoProperties.id,
|
identifier: editVideoProperties.id,
|
||||||
|
@ -38,7 +38,11 @@ import { useDropzone } from "react-dropzone";
|
|||||||
import AddIcon from "@mui/icons-material/Add";
|
import AddIcon from "@mui/icons-material/Add";
|
||||||
|
|
||||||
import { setNotification } from "../../../state/features/notificationsSlice.ts";
|
import { setNotification } from "../../../state/features/notificationsSlice.ts";
|
||||||
import { objectToBase64, objectToFile, uint8ArrayToBase64 } from "../../../utils/PublishFormatter.ts";
|
import {
|
||||||
|
objectToBase64,
|
||||||
|
objectToFile,
|
||||||
|
uint8ArrayToBase64,
|
||||||
|
} from "../../../utils/PublishFormatter.ts";
|
||||||
import { RootState } from "../../../state/store.ts";
|
import { RootState } from "../../../state/store.ts";
|
||||||
import {
|
import {
|
||||||
upsertVideosBeginning,
|
upsertVideosBeginning,
|
||||||
@ -65,7 +69,11 @@ import {
|
|||||||
QTUBE_PLAYLIST_BASE,
|
QTUBE_PLAYLIST_BASE,
|
||||||
QTUBE_VIDEO_BASE,
|
QTUBE_VIDEO_BASE,
|
||||||
} from "../../../constants/Identifiers.ts";
|
} from "../../../constants/Identifiers.ts";
|
||||||
import { maxSize, titleFormatter, videoMaxSize } from "../../../constants/Misc.ts";
|
import {
|
||||||
|
maxSize,
|
||||||
|
titleFormatter,
|
||||||
|
videoMaxSize,
|
||||||
|
} from "../../../constants/Misc.ts";
|
||||||
import { getFileName } from "../../../utils/stringFunctions.ts";
|
import { getFileName } from "../../../utils/stringFunctions.ts";
|
||||||
|
|
||||||
export const toBase64 = (file: File): Promise<string | ArrayBuffer | null> =>
|
export const toBase64 = (file: File): Promise<string | ArrayBuffer | null> =>
|
||||||
@ -138,7 +146,6 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => {
|
|||||||
useState(false);
|
useState(false);
|
||||||
const [imageExtracts, setImageExtracts] = useState<any>({});
|
const [imageExtracts, setImageExtracts] = useState<any>({});
|
||||||
|
|
||||||
|
|
||||||
const { getRootProps, getInputProps } = useDropzone({
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
accept: {
|
accept: {
|
||||||
"video/*": [],
|
"video/*": [],
|
||||||
@ -316,7 +323,7 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => {
|
|||||||
action: "PUBLISH_QDN_RESOURCE",
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
name: name,
|
name: name,
|
||||||
service: "DOCUMENT",
|
service: "DOCUMENT",
|
||||||
file: objectToFile(videoObject),
|
data64: await objectToBase64(videoObject),
|
||||||
title: title.slice(0, 50),
|
title: title.slice(0, 50),
|
||||||
description: metadescription,
|
description: metadescription,
|
||||||
identifier: identifier + "_metadata",
|
identifier: identifier + "_metadata",
|
||||||
@ -396,13 +403,12 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => {
|
|||||||
`**category:${category};subcategory:${subcategory};${codes}**` +
|
`**category:${category};subcategory:${subcategory};${codes}**` +
|
||||||
stringDescription.slice(0, 120);
|
stringDescription.slice(0, 120);
|
||||||
|
|
||||||
|
|
||||||
// Description is obtained from raw data
|
// Description is obtained from raw data
|
||||||
const requestBodyJson: any = {
|
const requestBodyJson: any = {
|
||||||
action: "PUBLISH_QDN_RESOURCE",
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
name: name,
|
name: name,
|
||||||
service: "PLAYLIST",
|
service: "PLAYLIST",
|
||||||
file: objectToFile(playlistObject),
|
data64: await objectToBase64(playlistObject),
|
||||||
title: title.slice(0, 50),
|
title: title.slice(0, 50),
|
||||||
description: metadescription,
|
description: metadescription,
|
||||||
identifier: identifier + "_metadata",
|
identifier: identifier + "_metadata",
|
||||||
@ -451,13 +457,12 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => {
|
|||||||
`**category:${playlistObject.category};subcategory:${playlistObject.subcategory};${codes}**` +
|
`**category:${playlistObject.category};subcategory:${playlistObject.subcategory};${codes}**` +
|
||||||
playlistObject.description.slice(0, 120);
|
playlistObject.description.slice(0, 120);
|
||||||
|
|
||||||
|
|
||||||
// Description is obtained from raw data
|
// Description is obtained from raw data
|
||||||
const requestBodyJson: any = {
|
const requestBodyJson: any = {
|
||||||
action: "PUBLISH_QDN_RESOURCE",
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
name: name,
|
name: name,
|
||||||
service: "PLAYLIST",
|
service: "PLAYLIST",
|
||||||
file: objectToFile( playlistObject),
|
data64: await objectToBase64(playlistObject),
|
||||||
title: playlistObject.title.slice(0, 50),
|
title: playlistObject.title.slice(0, 50),
|
||||||
description: metadescription,
|
description: metadescription,
|
||||||
identifier: selectExistingPlaylist.identifier,
|
identifier: selectExistingPlaylist.identifier,
|
||||||
@ -596,7 +601,9 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => {
|
|||||||
compressedFile = file;
|
compressedFile = file;
|
||||||
resolve();
|
resolve();
|
||||||
},
|
},
|
||||||
error(error) {console.log(error)},
|
error(error) {
|
||||||
|
console.log(error);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (!compressedFile) continue;
|
if (!compressedFile) continue;
|
||||||
@ -613,7 +620,9 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => {
|
|||||||
[index]: imagesExtracts,
|
[index]: imagesExtracts,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (error) {console.log(error)}
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -28,7 +28,7 @@ const ResponsiveImage: React.FC<ResponsiveImageProps> = ({
|
|||||||
}, endTimeMilliSeconds);
|
}, endTimeMilliSeconds);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => endLoading(5), []);
|
useEffect(() => endLoading(30), [endLoading]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
@ -156,7 +156,7 @@ export const CommentEditor = ({
|
|||||||
action: "PUBLISH_QDN_RESOURCE",
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
name: name,
|
name: name,
|
||||||
service: "BLOG_COMMENT",
|
service: "BLOG_COMMENT",
|
||||||
file: stringToFile(value),
|
data64: utf8ToBase64(value),
|
||||||
identifier: identifier,
|
identifier: identifier,
|
||||||
});
|
});
|
||||||
dispatch(
|
dispatch(
|
||||||
|
@ -85,7 +85,7 @@ export const LikeAndDislike = ({ name, identifier }: LikeAndDislikeProps) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function publishLike(chosenLikeType: LikeType) {
|
const publishLike = async (chosenLikeType: LikeType) => {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
dispatch(
|
dispatch(
|
||||||
setNotification({
|
setNotification({
|
||||||
@ -118,21 +118,17 @@ export const LikeAndDislike = ({ name, identifier }: LikeAndDislikeProps) => {
|
|||||||
throw new Error("Could not retrieve content creator's address");
|
throw new Error("Could not retrieve content creator's address");
|
||||||
});
|
});
|
||||||
|
|
||||||
objectToBase64({
|
await qortalRequest({
|
||||||
likeType: chosenLikeType,
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
}).then(likeToBase64 => {
|
name: username,
|
||||||
qortalRequest({
|
service: "CHAIN_COMMENT",
|
||||||
action: "PUBLISH_QDN_RESOURCE",
|
data64: await objectToBase64({ likeType: chosenLikeType }),
|
||||||
name: username,
|
title: "",
|
||||||
service: "CHAIN_COMMENT",
|
identifier: likeIdentifier,
|
||||||
data64: likeToBase64,
|
filename: `like_metadata.json`,
|
||||||
title: "",
|
|
||||||
identifier: likeIdentifier,
|
|
||||||
filename: `like_metadata.json`,
|
|
||||||
}).then(() => {
|
|
||||||
updateLikeDataState(chosenLikeType);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateLikeDataState(chosenLikeType);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
dispatch(
|
dispatch(
|
||||||
setNotification({
|
setNotification({
|
||||||
@ -146,7 +142,7 @@ export const LikeAndDislike = ({ name, identifier }: LikeAndDislikeProps) => {
|
|||||||
);
|
);
|
||||||
throw new Error("Failed to publish Super Like");
|
throw new Error("Failed to publish Super Like");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -129,7 +129,7 @@ export const SuperLike = ({
|
|||||||
39
|
39
|
||||||
)}_${id}`;
|
)}_${id}`;
|
||||||
|
|
||||||
const superLikeToFile = objectToFile({
|
const superLikeToBase64 = await objectToBase64({
|
||||||
comment,
|
comment,
|
||||||
transactionReference: res.signature,
|
transactionReference: res.signature,
|
||||||
notificationInformation: {
|
notificationInformation: {
|
||||||
@ -147,7 +147,7 @@ export const SuperLike = ({
|
|||||||
action: "PUBLISH_QDN_RESOURCE",
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
name: username,
|
name: username,
|
||||||
service: "BLOG_COMMENT",
|
service: "BLOG_COMMENT",
|
||||||
file: superLikeToFile,
|
data64: superLikeToBase64,
|
||||||
title: "",
|
title: "",
|
||||||
description: metadescription,
|
description: metadescription,
|
||||||
identifier: identifierSuperLike,
|
identifier: identifierSuperLike,
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
import { Box, Button, TextField } from "@mui/material";
|
import localforage from "localforage";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { RootState } from "../../../state/store";
|
|
||||||
import ShortUniqueId from "short-unique-id";
|
import ShortUniqueId from "short-unique-id";
|
||||||
|
import { COMMENT_BASE } from "../../../constants/Identifiers.ts";
|
||||||
import { setNotification } from "../../../state/features/notificationsSlice";
|
import { setNotification } from "../../../state/features/notificationsSlice";
|
||||||
|
import { addtoHashMapSuperlikes } from "../../../state/features/videoSlice";
|
||||||
|
import { RootState } from "../../../state/store";
|
||||||
import {
|
import {
|
||||||
objectToBase64,
|
objectToBase64,
|
||||||
objectToFile,
|
objectToFile,
|
||||||
publishFormatter,
|
|
||||||
stringToFile,
|
stringToFile,
|
||||||
} from "../../../utils/PublishFormatter.ts";
|
} from "../../../utils/PublishFormatter.ts";
|
||||||
import localforage from "localforage";
|
|
||||||
import {
|
import {
|
||||||
CommentInput,
|
CommentInput,
|
||||||
CommentInputContainer,
|
CommentInputContainer,
|
||||||
SubmitCommentButton,
|
SubmitCommentButton,
|
||||||
} from "./Comments-styles";
|
} from "./Comments-styles";
|
||||||
import { addtoHashMapSuperlikes } from "../../../state/features/videoSlice";
|
|
||||||
import { COMMENT_BASE } from "../../../constants/Identifiers.ts";
|
|
||||||
const uid = new ShortUniqueId();
|
const uid = new ShortUniqueId();
|
||||||
|
|
||||||
const notification = localforage.createInstance({
|
const notification = localforage.createInstance({
|
||||||
@ -160,7 +159,7 @@ export const CommentEditor = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let dataFile = null;
|
let dataFile: string = null;
|
||||||
let description = "";
|
let description = "";
|
||||||
let tag1 = "";
|
let tag1 = "";
|
||||||
let superObj = {};
|
let superObj = {};
|
||||||
@ -181,8 +180,7 @@ export const CommentEditor = ({
|
|||||||
notificationInformation: comment.notificationInformation,
|
notificationInformation: comment.notificationInformation,
|
||||||
about: comment.about,
|
about: comment.about,
|
||||||
};
|
};
|
||||||
const superLikeToFile = objectToFile(superObj);
|
dataFile = await objectToBase64(superObj);
|
||||||
dataFile = superLikeToFile;
|
|
||||||
}
|
}
|
||||||
if (isSuperLike && !dataFile)
|
if (isSuperLike && !dataFile)
|
||||||
throw new Error("unable to edit Super like");
|
throw new Error("unable to edit Super like");
|
||||||
@ -191,7 +189,7 @@ export const CommentEditor = ({
|
|||||||
action: "PUBLISH_QDN_RESOURCE",
|
action: "PUBLISH_QDN_RESOURCE",
|
||||||
name: name,
|
name: name,
|
||||||
service: "BLOG_COMMENT",
|
service: "BLOG_COMMENT",
|
||||||
file: isSuperLike ? dataFile : stringToFile(value),
|
data64: isSuperLike ? dataFile : utf8ToBase64(value),
|
||||||
identifier: identifier,
|
identifier: identifier,
|
||||||
description,
|
description,
|
||||||
tag1,
|
tag1,
|
||||||
|
@ -147,7 +147,7 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>(
|
|||||||
|
|
||||||
const increaseSpeed = (wrapOverflow = true) => {
|
const increaseSpeed = (wrapOverflow = true) => {
|
||||||
const changedSpeed = playbackRate + speedChange;
|
const changedSpeed = playbackRate + speedChange;
|
||||||
let newSpeed = wrapOverflow
|
const newSpeed = wrapOverflow
|
||||||
? changedSpeed
|
? changedSpeed
|
||||||
: Math.min(changedSpeed, maxSpeed);
|
: Math.min(changedSpeed, maxSpeed);
|
||||||
|
|
||||||
@ -194,6 +194,7 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>(
|
|||||||
identifier,
|
identifier,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
} finally {
|
} finally {
|
||||||
isFetchingProperties.current = false;
|
isFetchingProperties.current = false;
|
||||||
}
|
}
|
||||||
@ -201,8 +202,10 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>(
|
|||||||
|
|
||||||
const toggleRef = useRef<any>(null);
|
const toggleRef = useRef<any>(null);
|
||||||
const { downloadVideo } = useContext(MyContext);
|
const { downloadVideo } = useContext(MyContext);
|
||||||
const togglePlay = async (event?: any, isPlay?: boolean) => {
|
|
||||||
|
const togglePlay = (event?: any, isPlay?: boolean) => {
|
||||||
if (!videoRef.current) return;
|
if (!videoRef.current) return;
|
||||||
|
|
||||||
setStartPlay(true);
|
setStartPlay(true);
|
||||||
if (!src || resourceStatus?.status !== "READY") {
|
if (!src || resourceStatus?.status !== "READY") {
|
||||||
const el = document.getElementById("videoWrapper");
|
const el = document.getElementById("videoWrapper");
|
||||||
@ -429,7 +432,7 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>(
|
|||||||
|
|
||||||
function formatTime(seconds: number): string {
|
function formatTime(seconds: number): string {
|
||||||
seconds = Math.floor(seconds);
|
seconds = Math.floor(seconds);
|
||||||
let minutes: number | string = Math.floor(seconds / 60);
|
const minutes: number | string = Math.floor(seconds / 60);
|
||||||
let hours: number | string = Math.floor(minutes / 60);
|
let hours: number | string = Math.floor(minutes / 60);
|
||||||
|
|
||||||
let remainingSeconds: number | string = seconds % 60;
|
let remainingSeconds: number | string = seconds % 60;
|
||||||
@ -473,7 +476,9 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>(
|
|||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
}
|
}
|
||||||
}, 7500);
|
}, 7500);
|
||||||
} catch (error) {}
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user