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

Stop other videos after lazyload new one - jQuery and YouTube API

$
0
0

My Scenario - Codepen (Don't forget to scroll down)

I'm using the lazyframe plugin to lazyload my YouTube iframe videos. Each video gets added to the DOM after a click on the play button. There is a onAppend function included which gets triggered after a new video iframe is created (please have a look at the pen I created).

How can I stop the other vids after starting a new one?

I put a alert into the onAppend function to check if it works fine. The onAppend part looks like

    onAppend: function(e) {        alert('onAppend after Lazyframe Function');                        }

I also managed to include the following scripts

<script src="http://www.youtube.com/player_api"></script><script src="http://www.youtube.com/iframe_api"></script>

The part at the end of the embed YoutTube URL to enable the API is also include

&enablejsapi=1

Each Iframe gets a unique id

<iframe id="lazyframe-6hgVihWjK2c" src="https://www.youtube.com/embed/6hgVihWjK2c/?autoplay=1" allowfullscreen="" class="test-vidx" frameborder="0"></iframe>

Any help would be appreciated.


Viewing all articles
Browse latest Browse all 3831

Trending Articles



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