修复视频获取帧图问题
This commit is contained in:
parent
d6f48301ef
commit
c1eeca4e81
|
@ -286,51 +286,49 @@ export default function CreateProfile() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (isPrice) return;
|
||||
if (isSubmitting) return;
|
||||
const superfan_price_list = superSingle.map((it, index) => ({
|
||||
period: index,
|
||||
enable: it.enable ? 1 : 0,
|
||||
price: parseInt(it.price * 100, 10),
|
||||
is_superfanship_give_wechat: it.wechatFree ? 1 : 0,
|
||||
}));
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
const body = {
|
||||
profile: spaceIntro,
|
||||
admission_price: parseInt(spacePrice * 100, 10),
|
||||
ironfanship_price: parseInt(ironFanPrice * 100, 10),
|
||||
is_superfanship_enabled: openSuper ? 1 : 0,
|
||||
superfan_price_list,
|
||||
};
|
||||
const _data = await requireAPI(
|
||||
"POST",
|
||||
"/api/zone/create",
|
||||
{
|
||||
body,
|
||||
},
|
||||
true
|
||||
);
|
||||
if (_data.ret === -1) {
|
||||
Toast.show({
|
||||
icon: "fail",
|
||||
content: _data.msg,
|
||||
position: "top",
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isPrice) return;
|
||||
const superfan_price_list = superSingle.map((it, index) => ({
|
||||
period: index,
|
||||
enable: it.enable ? 1 : 0,
|
||||
price: parseInt(it.price * 100, 10),
|
||||
is_superfanship_give_wechat: it.wechatFree ? 1 : 0,
|
||||
}));
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
const body = {
|
||||
profile: spaceIntro,
|
||||
admission_price: parseInt(spacePrice * 100, 10),
|
||||
ironfanship_price: parseInt(ironFanPrice * 100, 10),
|
||||
is_superfanship_enabled: openSuper ? 1 : 0,
|
||||
superfan_price_list,
|
||||
};
|
||||
const _data = await requireAPI(
|
||||
"POST",
|
||||
"/api/zone/create",
|
||||
{
|
||||
body,
|
||||
},
|
||||
true
|
||||
);
|
||||
if (_data.ret === -1) {
|
||||
Toast.show({
|
||||
icon: "success",
|
||||
content: "开通空间成功!空间简介将在审核完成后生效。",
|
||||
icon: "fail",
|
||||
content: _data.msg,
|
||||
position: "top",
|
||||
});
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
return;
|
||||
}
|
||||
Toast.show({
|
||||
icon: "success",
|
||||
content: "开通空间成功!空间简介将在审核完成后生效。",
|
||||
position: "top",
|
||||
});
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
return (
|
||||
|
|
|
@ -494,10 +494,13 @@ export default function CompleteStreamerInformation() {
|
|||
};
|
||||
const creatVideoCanvas = (file) => {
|
||||
if (typeof window == "undefined") return;
|
||||
const videoD = document.getElementById("videoD");
|
||||
const videoD = document.getElementById("video_complete");
|
||||
const url = URL.createObjectURL(file);
|
||||
videoD.src = url;
|
||||
videoD.addEventListener("loadeddata", function () {
|
||||
videoD.currentTime = 1;
|
||||
});
|
||||
videoD.addEventListener("seeked", function () {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = videoD.videoWidth;
|
||||
canvas.height = videoD.videoHeight;
|
||||
|
@ -1127,6 +1130,12 @@ export default function CompleteStreamerInformation() {
|
|||
<SpinLoading color="default" />
|
||||
</div>
|
||||
</Mask>
|
||||
<div className="hidden">
|
||||
<video id="video_complete" controls autoPlay name="media">
|
||||
<source />
|
||||
您的浏览器不支持 Video 标签。
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -191,10 +191,13 @@ export default function EditStreamerMedia() {
|
|||
|
||||
const creatVideoCanvas = (file) => {
|
||||
if (typeof window == "undefined") return;
|
||||
const videoD = document.getElementById("videoD");
|
||||
const videoD = document.getElementById("video_edit_streamer");
|
||||
const url = URL.createObjectURL(file);
|
||||
videoD.src = url;
|
||||
videoD.addEventListener("loadeddata", function () {
|
||||
videoD.currentTime = 1;
|
||||
});
|
||||
videoD.addEventListener("seeked", function () {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = videoD.videoWidth;
|
||||
canvas.height = videoD.videoHeight;
|
||||
|
@ -361,7 +364,7 @@ export default function EditStreamerMedia() {
|
|||
</div>
|
||||
</div>
|
||||
<div className="hidden">
|
||||
<video id="videoD" controls autoPlay name="media">
|
||||
<video id="video_edit_streamer" controls name="media">
|
||||
<source />
|
||||
您的浏览器不支持 Video 标签。
|
||||
</video>
|
||||
|
|
|
@ -100,19 +100,20 @@ export default function UploadImgs({
|
|||
};
|
||||
const creatVideoCanvas = (file) => {
|
||||
if (typeof window == "undefined") return;
|
||||
const videoD = document.getElementById("videoD");
|
||||
const videoD = document.getElementById("video_upload");
|
||||
const url = URL.createObjectURL(file);
|
||||
videoD.src = url;
|
||||
videoD.addEventListener("loadeddata", function () {
|
||||
videoD.currentTime = 0;
|
||||
videoD.pause(); // 可选:确保视频在重置后不会自动播放
|
||||
videoD.currentTime = 1;
|
||||
});
|
||||
videoD.addEventListener("seeked", function () {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = videoD.videoWidth;
|
||||
canvas.height = videoD.videoHeight;
|
||||
canvas
|
||||
.getContext("2d")
|
||||
.drawImage(videoD, 0, 0, canvas.width, canvas.height);
|
||||
const canvasImg = canvas.toDataURL();
|
||||
const canvasImg = canvas.toDataURL("image/png");
|
||||
setFrameImage((old) => ({ ...old, src: canvasImg }));
|
||||
setFilesUrls([canvasImg]);
|
||||
// 释放URL对象
|
||||
|
@ -176,7 +177,7 @@ export default function UploadImgs({
|
|||
</label>
|
||||
<input
|
||||
type="file"
|
||||
multiple="multiple"
|
||||
multiple={type == 1}
|
||||
id="uploadAvatarBtn"
|
||||
style={{ display: "none" }}
|
||||
// accept="image/png, image/jpeg, video/*"
|
||||
|
@ -188,7 +189,7 @@ export default function UploadImgs({
|
|||
)}
|
||||
</div>
|
||||
<div className="hidden">
|
||||
<video id="videoD" controls autoPlay name="media">
|
||||
<video id="video_upload" controls autoPlay name="media">
|
||||
<source />
|
||||
您的浏览器不支持 Video 标签。
|
||||
</video>
|
||||
|
|
Loading…
Reference in New Issue