Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
Am I missing some code to view this video in a react app using visual studio code [react]

App.js

import React from 'react';
import ReactDOM from 'react-dom';

import { Menu } from './Menu';
import { Video } from './Video';

const VIDEOS = {
  fast: require('./videos/bel.mp4'),
  slow: require('./videos/mimi.mp4'),
  cute: require('./videos/coco.mp4'),
  eek: require('./videos/drea.mp4') 
};

export class App extends React.Component {
  constructor(props){
    super(props);

    this.state = {
      src: VIDEOS.fast
    };
  }

  render() {
    return(
      <div>
        <Menu  />
        <Video src={this.state.src} />
      </div>
    );
  }
}

ReactDOM.render(
  <App />,
  document.getElementById('app')
);

Video.js

import React from 'react';

export class Video extends React.Component {
    render() {
        return(
            <div>
                <video controls autoPlay muted src={this.props.src}/>
            </div>
        );
    }
}

Menu.js

import React from 'react';

export class Menu extends React.Component {
    render(){
        return(
            <form>
                <input type="radio" name="src" value="fast"  /> Bella
                <input type="radio" name="src" value="slow"  /> Coco
                <input type="radio" name="src" value="cute"  /> Mimi
                <input type="radio" name="src" value="eek"  /> Drea
            </form>
        );
    }
}

Trying to create a small React app to practice on my personal computer but the video isn't playing, not sure what I am missing. Video player shows and radio buttons are visible but video doesn't play. I know there is more that needs to be done but first I want to have the first video play that is why I set this.state to VIDEOS.fast

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try importing the videos like this maybe ?

import bel from './videos/bel.mp4';
import mimi from './videos/mimi.mp4';
import coco from './videos/coco.mp4';
import drea from './videos/drea.mp4';

const VIDEOS = {
  fast: bel,
  slow: mimi,
  cute: coco,
  eek: drea
};

And then don't forget the type attribute in the video tag

<video controls autostart autoPlay src={bel} type="video/mp4" />
about 4 years ago · Juan Pablo Isaza Relatório

0

The most likely issue is that React is not recognising that you are updating the video source and is not doing a video load.

This is a known characteristic - essentially you have to watch for a change in the src and when you see it trigger a load of the video.

There is a nice example in this answer here: https://stackoverflow.com/a/47382850/334402

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda