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