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

363
Visualizações
Autoplay a video within slick slider

I'm using slick slider downloaded from http://kenwheeler.github.io/slick/

I have a number of images on autoplay displaying correctly, however, i also have an mp4 file that i cant get to autoplay. Here is my HTML:

<section class="regular slider" style="width: 900px; left: 60px; top: 230px;">
    <div>        
        <video autoplay>
            <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4">
        </video>
    </div>
    <div>
      <img src="https://placehold.it/350x300?text=2">
    </div>
    <div>
      <img src="https://placehold.it/350x300?text=3">
    </div>
 </section>

And here is my script:

<script type="text/javascript">
    $(document).on('ready', function() {
      $(".regular").slick({
        dots: true,
        infinite: true,
        slidesToShow: 1,
        slidesToScroll: 1,
          autoplay: true,
          autoplaySpeed: 2000
      });
     });
  </script>
about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I quote @AsafDavid. Look at the working code example in the original answer.

Yes it can be done using JavaScript. When the video slide becomes the currentSlide you have to:

  1. pause the slider
  2. play the video

You can do this using the afterChange event:

$('.sliderMain').on('afterChange', function(event, slick, currentSlide){ 
  if (currentSlide == 5) { 
    $('.sliderMain').slick('slickPause'); myVideo.play(); 
  } 
});
about 4 years ago · Santiago Trujillo Relatório

0

You can use the afterChange Callback function to achieve this.

$('.your-element').on('afterChange', function(event, slick, currentSlide, nextSlide){
    $('#video')[0].play(); 
});
about 4 years ago · Santiago Trujillo Relatório

0

Video needs to be muted for autoplay to work.

<video autoplay muted>
     <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4">
</video>
about 4 years ago · Santiago Trujillo 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