Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda