Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3722

YouTube iFrame API for Loop

$
0
0

I want to create loop for youtube iframe API, what I am trying is

var tag = document.createElement('script');tag.src = "https://www.youtube.com/iframe_api";var firstScriptTag = document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var vidslide1, vidslide2, vidslide3;function onYouTubeIframeAPIReady() {        for(var i = 0; i < vidslide.length;i++) {          vidslide[i] = new YT.Player(vidslide[i], {            events: {'onStateChange': onPlayerStateChange            }          });           }   }

But its not working. I am trying to create 3 iframes in slider.

Here is my html.

<?php $count = 0; ?>           <?php foreach($sliders->results() as $slider): $count++; ?><div class="item"><iframe id="vidslide<?php echo $count; ?>" class="embed-responsive-item" width="75%" height="500" src="<?php _lang($slider['url'])?>?enablejsapi=1" frameborder="0" allowfullscreen></iframe>           </div><?php endforeach ?>

Anyone can help?


Viewing all articles
Browse latest Browse all 3722

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>