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

165
Vistas
Automatically Pause Embedded iFrame Vimeo Video at Specific Time?

I'm using a Vimeo video-embed (iFrame embed code from their website) on my website, and I need the video to automatically stop at a specific timestamp (I'll use 6 seconds here) whenever users of my site play the video. The content after the timestamp is unnecessary.

But unlike YouTube, Vimeo doesn't seem to have an easy way to set end times for any video you embed from them. Unfortunately, I do not own the video so I can't edit the footage directly, so I believe a JavaScript solution is the best option.

Here's the aforementioned iFrame embed HTML from Vimeo that I use on my site:

<iframe id="vidz" src="https://player.vimeo.com/video/401649410?h=11d74aa27c&amp;portrait=0" width="450" height="253" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen=""></iframe>

Upon trying to select elements within the iFrame (like the video itself), my JS selectors don't seem to be working at all, perhaps because the video is from a separate source not hosted on my site?

Here's code I've been working with, but it doesn't appear to be interacting with the iFrame, as I believe I would need to add this eventListener to a video, directly. But I can't select the embeded video via JS either, it seems. So I'm not quite sure how to handle this:

var vid = document.querySelector("#vidz");
vid.addEventListener("timeupdate", function(){
if(t >= 6000) 
  {
vid.pause();
  }
});

I can also provide the HTML to any elements within the iFrame, but again, I'm not sure how I'd be able to interact with those elements.

Any ideas? Any and all help would be deeply appreciated. Cheers.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

use Vimeo js file and below is a script you want video will pause after 6 minutes (specific time) (360 means 6 minutes)

    <script src="https://player.vimeo.com/api/player.js"></script>

    var iframe = document.querySelector('iframe');
    var player = new Vimeo.Player(iframe);
    function foo() {
        
        player.getCurrentTime().then(function(time) {
            console.log('time:', time);
            if(time >= 360){  
                player.pause()
            }
        });
        setTimeout(foo, 1000);
    }
    player.on('play', function() {
        foo();
    });
</script>
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