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

183
Vistas
Sequential Events on JavaScript for on Function

For video player, there are 3 actions: play, pause and continue. For continue action, it is defined as play after being pause.

If I have 2 functions already defined for play and pause:

videoPlayer.on('play', function () {
      //play video
});
videoPlayer.on('pause', function () {
      //pause video
});

I am having trouble defining the sequential action of pause -> play. Would the below function work for continue?

videoPlayer.on('pause').on('play', function () {
       //Continue video           
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If I understood your question correctly, you could use promises to wait till the video is paused

function playP() {
    videoPlayer.on('play', function () {
        //play video
    });
}

function pauseP() {
    return new Promise((res, rej) => {
        videoPlayer.on('pause', function () {
            // do stuff
            res(true);
        });
    })
}

pauseP().then((x) => {
    if (x) 
        playP();
})

This code will wait till the video is paused to start listening for the play event.

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