Here I tried to play audio and video simultaneously, but the page goes blank when I try to run it. Is there a way I can fix this? This is the code
import React from 'react'
import './home.css'
import { useState } from 'react';
import { useEffect } from 'react';
import video1 from './Ankit.mp4';
import Newhome from './Newhome';
import audio from './sound.mp3';
export default function Home() {
const [showVideo, setShowVideo] = useState(true);
useEffect(
() => {
let timer1 = setTimeout(() => setShowVideo(false), 3500);
return () => {
// <div>Best viewed on mobile for now</div>
clearTimeout(timer1);
};
},
[]
);
return (
<>
{showVideo ? <video muted autoPlay loop className='logo_video2' >
<source src={video1} type="video/mp4" />
<audio controls>
<source src={audio} type="audio/mpeg" />
</audio>
</video> : <Newhome/>}
</>
)
}
showVideo
is used to play a logo and 3.5 seconds after all content will be displayed.