preload={"metadata"}

main
tt 9 months ago
parent 4cd62c0822
commit ffda596018

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

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

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

Loading…
Cancel
Save