0

i have a wordpress page with jetpack infinity scroll and at all my posts is a youtubevideo at the first page befor the infinity scroll load page 2 and 3 work all great autoplay work for youtube and all this but when the infinity scroll work and load page 2 the video from youtube dont play more at this only the video from the first page what can i do my javascript for autoplay look like this:

        window.onload=function(){   
        var LoadVideo = function(player_id){    
            var Program = { 
                Init: function(){   
                    this.NewPlayer();   
                    this.EventHandler();    
                },  
                NewPlayer: function(){  
                    var _this = this;   
                    this.Player = new YT.Player(player_id, {    
                        events: {   
              'onStateChange': onPlayerStateChange, 
            }   
                    }); 
                    _this.Player.$element = $('#' + player_id); 
                },  
                Play: function(){   
                    if( this.Player.getPlayerState() === 1 ) return;
                    this.Player.playVideo();    
                },  
                Pause: function(){  
                    if( this.Player.getPlayerState() === 2 ) return;
                    this.Player.pauseVideo();   
                },  
                ScrollControl: function(){  
                    if( Utils.IsElementInViewport(this.Player.$element[0]) ) this.Play();
                    else this.Pause();  
                },  
                EventHandler: function(){   
                    var _this = this;   
                    $(window).on('scroll', function(){  
                        _this.ScrollControl();  
                    }); 
                }   
            };  
            var Utils = {   
                IsElementInViewport: function(el){  
                    if (typeof jQuery === "function" && el instanceof jQuery) el = el[0];   
                    var rect = el.getBoundingClientRect();  
                    return (    
                        rect.top >= 0 &&    
                        rect.left >= 0 &&   
                        rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && 
                        rect.right <= (window.innerWidth || document.documentElement.clientWidth)   
                    );  
                }   
            };  
d00nn1234
  • 27
  • 5
  • Sorry but your question is incomprehensible, can you explain it correctly? – Paul Oct 09 '17 at 08:37
  • i am so sory my english is not so good at the first 10 posts in the first page work ok but the jetpack infinity scroll load page number 2 with youtube videos and they videos from page 2 ar note autoplay with this codes – d00nn1234 Oct 09 '17 at 08:44

0 Answers0