VideoJS - allowing only one video to play at a time

Hello there.

I am new to the forums but Ive been happily using webflow for over 6 months and in the process of building a portfolio site. My problem involves a page I build that contains several videos, in which I am using some custom code to allow only one video player to play at a time. I got the example working on codepen but when I try to bring the code into webflow it doesnt work and cant figure out why so I came here hoping for some help.

A few things to note:

Here is the code snippet

 $(".video-js").each(function (videoIndex) {

var videoId = $(this).attr("id");

videojs(videoId).ready(function(){
    this.on("play", function(e) {
        //pause other video
        $(".video-js").each(function (index) {
            if (videoIndex !== index) {
                this.player.pause();
            }
        });
    });
});

});

Here is the working codepen example

Here is my site Read-Only:https://preview.webflow.com/preview/videojs-video?utm_medium=preview_link&utm_source=dashboard&utm_content=videojs-video&preview=0a3efe64065860d2eb828a8bb833bb6b&mode=preview

1 Like

I believe I solved this by removing "async" from the script tag
Thanks