Video slider: stop when the video is switched
Hi everyone,
I have created a video slider embedding Youtube videos (using tag <iframe>), that is, I have two videos that switch between one and the other when I click on a circle that I have taken from fontawesome.com. When I clic on the bottom PLAY to start the video, it does not stop when I switch to the next video of the slider. I would like when I change the video, the previous one is stopped.
I show below the js code that I have written so far. If you can help me to know what I should include in this code for the stop of the video that I switch it.
- $(document).ready(function(){
- var videoItems = $('.slidervideo li').length;
- // Pagination --
- for(i= 1; i <= videoItems; i++){
- $('.pagination-slider').append('<li><span class="fa fa-circle"></span>
- </li>');
- }
- //------------------------
- $('.slidervideo li').hide(); // Ocultanos todos los slides
- $('.slidervideo li:first').show(); // Mostramos el primer slide
- $('.pagination-slider li:first').css({'color': '#CD6E2E'});
- //Ejecutamos todas las funciones
- $('.pagination-slider li').click(paginationslider);
- // FUNCIONES =========================================================
- function paginationslider(){
- var paginationsliderPos = $(this).index() + 1;
- $('.slidervideo li').hide();
- $('.slidervideo li:nth-child('+ paginationsliderPos +')').fadeIn();
- $('.pagination-slider li').css({'color': '#858585'});
- $(this).css({'color': '#CD6E2E'});
- }
- });