preload={"metadata"}

main
tt 9 months ago
parent 4cd62c0822
commit ffda596018

@ -34,7 +34,7 @@ const PageComponent = ({
const handleSubmit = async (e: { preventDefault: () => void }) => { const handleSubmit = async (e: { preventDefault: () => void }) => {
e.preventDefault(); e.preventDefault();
if (!textStr) { if (!textStr) {
setVideoList(randomVideo()); setVideoList(randomVideo(3));
return; return;
} }
setShowLoadingModal(true); setShowLoadingModal(true);
@ -167,6 +167,7 @@ const PageComponent = ({
controls={true} controls={true}
autoPlay={true} autoPlay={true}
src={video.url} src={video.url}
preload={"metadata"}
></video> ></video>
</div> </div>
<div className={"text-gray-500"}> <div className={"text-gray-500"}>
@ -196,6 +197,7 @@ const PageComponent = ({
controls={true} controls={true}
autoPlay={false} autoPlay={false}
src={item.url} src={item.url}
preload={"metadata"}
></video> ></video>
</div> </div>
<div className={"text-gray-500"}> <div className={"text-gray-500"}>
@ -230,6 +232,7 @@ const PageComponent = ({
autoPlay={false} autoPlay={false}
controlsList={"nodownload"} controlsList={"nodownload"}
src={item.videoUrl} src={item.videoUrl}
preload={"metadata"}
></video> ></video>
</div> </div>
<div className={"text-gray-500"}> <div className={"text-gray-500"}>

@ -21,7 +21,7 @@ export default async function IndexPage({params: {locale = ''}}) {
prompt: t('prompt'), prompt: t('prompt'),
}; };
const initVideoList = randomVideo(); const initVideoList = randomVideo(3);
return ( return (

@ -290,12 +290,12 @@ export const allVideoList = [
] ]
export const randomVideo = () => { export const randomVideo = (count:number) => {
// 定义一个空数组来存放随机数 // 定义一个空数组来存放随机数
let randomNumbers = []; let randomNumbers = [];
const resultVideoList = []; const resultVideoList = [];
// 循环获取多个不同的随机数 // 循环获取多个不同的随机数
while (randomNumbers.length < 5) { while (randomNumbers.length < count) {
let randomNumber = Math.floor(Math.random() * (allVideoList.length + 1)); let randomNumber = Math.floor(Math.random() * (allVideoList.length + 1));
if (!randomNumbers.includes(randomNumber)) { if (!randomNumbers.includes(randomNumber)) {
randomNumbers.push(randomNumber); randomNumbers.push(randomNumber);

Loading…
Cancel
Save