javascript - Turn on schuffle when click jQuery -
i trying make random play, click button, automatically after film opened next.
this code works when movie finish have manually click #schuffle , opens next item. want had click once , activated code every time when film completed, is, return 0.
$(document).ready(function() { $("#schuffle").on('click',function(e) { //ytplayer.getplayerstate() return 0 when video finish //if youtube video finish if ( ytplayer.getplayerstate() == 0 ) { //click random element out .koncentrator a.utwor var list = $('.koncentrator a.utwor'); //click random .koncentrator a.utwor list.eq(parseint(math.random()*list.length)).click(); //scroll element $(".active").get(0).scrollintoview(); } }); });
what this? if user clicks on button activates setinterval checkyoutubevideo() every second.
function checkyoutubevideo() { //ytplayer.getplayerstate() return 0 when video finish //if youtube video finish if ( ytplayer.getplayerstate() == 0 ) { //click random element out .koncentrator a.utwor var list = $('.koncentrator a.utwor'); //click random .koncentrator a.utwor list.eq(parseint(math.random()*list.length)).click(); //scroll element $(".active").get(0).scrollintoview(); } } $(document).ready(function() { $("#schuffle").on('click',function(e) { setinterval(checkyoutubevideo(), 1000); }); });
Comments
Post a Comment