Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video Render in NEXTJS

I'm using NextJS and I was trying to put a video as a background. In the FIRST render everything works fine, but when I reload the screen, the video doesn't run in the autoplay mode.

Code:

import React from 'react'
import MainHeader from '../components/MainHeader'
import { Container } from '../styles/pages/Home'

const Home: React.FC = () => {
  return (
    <Container>
      <MainHeader />
      <video autoPlay style={{ width: '500px', height: '500px' }}>
        <source src="/blue.mp4" />
      </video>
    </Container>
  )
}

export default Home

How can I fix that?

like image 593
Ricardo Lopes Avatar asked Mar 07 '26 07:03

Ricardo Lopes


1 Answers

I have added the loop to your code. I hope it solves your problem

import React from 'react'
import MainHeader from '../components/MainHeader'
import { Container } from '../styles/pages/Home'

const Home: React.FC = () => {
  return (
    <Container>
    <MainHeader />
      <video autoPlay loop style={{ width: '500px', height: '500px' }}>
        <source src="/blue.mp4" />
      </video>
    </Container>
   )
 }

export default Home
like image 161
Ndifreke Umoren Avatar answered Mar 09 '26 22:03

Ndifreke Umoren



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!