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

108
Visualizações
How to add an observer to react hooks?

I'm trying to make a live stream feature, I have an array of programs (videos), every video has startDate and endDate. If I'm running some video and the current time equals the end time of the video, it should run the main function (that calculates the time and run the new video).

const programs = [
    { video: "URL", startDate: 1644405993, endDate: 1644406032 },
    { video: "URL", startDate: 1644405993, endDate: 1644406032 },
    { video: "URL", startDate: 1644405993, endDate: 1644406032 },
    { video: "URL", startDate: 1644405993, endDate: 1644406032 }
];

Can I add any observer for example to run the function when the current time equals the end time of the current program or I can make it in another way?

The main function that should be run again:

  const runningVideo = (newPrograms) => {
    const curTime = Math.floor(new Date().getTime() / 1000);
    const currentProgram = newPrograms.filter(
      p => p.startDate < curTime && p.endDate > curTime
    );
    setPlayerDetails(currentProgram.length ? currentProgram[0].videoPath : advertisement)
  };

**NOTE: ** It's a live stream so every program depends on the start and the end time, I mean the video shouldn't be ended to start the next video, so I can't use onEndedVideo for example.

about 4 years ago · Juan Pablo Isaza
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