1

I have used input tag in react js to select video element but it is not previewing the video, but after I save my code by commenting and uncommenting then the video is previewed. How to solve this problem

const handleChange = (event) => {
    const file = event.target.files[0];
    if (!file) return;
    setVideoSrc(URL.createObjectURL(file));
};
<input
    type='file'
    className='form-control form-control-sm'
    id='media-URL'
    accept='image/*,audio/*,gif/*,video/mp4,video/x-m4v,video/*'
    onChange={(event) => {
    handleChange(event);
        }
    }
    />
 <video width='260' height='150' controls>
     <source src={videoSrc} />
     Your browser does not support the video tag.
 </video>

enter image description here

Navneet
  • 47
  • 8

0 Answers0