I have multiple videos on my page I want to play one video at a time. IF one video plays then other videos need to stop playing. I am using javascript code for video play pause.
<section id="gallery" class="bg-lighter">
<div class="container-fluid pt-70 pb-0">
<div class="section-content">
<div class="row">
<div class="col-md-12">
<div id="grid" class="gallery-isotope grid-4 gutter clearfix">
<?php if(!empty($page_info[0]['link1'])){ ?>
<div class="gallery-item photography">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb galerryVideoCopy">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r($page_info[0]['link1']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<p style="color: white"><?php echo $page_info[0]['link1_urdu']?></p>
<p style="color: white"><?php echo $page_info[0]['link1_hindi']?></p>
<p style="color: white"><?php echo $page_info[0]['link1_eng']?></p>
</div>
</div>
<?php } ?>
<?php if(!empty($page_info[0]['link2'])){ ?>
<div class="gallery-item branding">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb galerryVideoCopy">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link2']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<p style="color: white"><?php echo $page_info[0]['link2_urdu']?></p>
<p style="color: white"><?php echo $page_info[0]['link2_hindi']?></p>
<p style="color: white"><?php echo $page_info[0]['link2_eng']?></p>
</div>
</div>
<?php } ?>
<?php if(!empty($page_info[0]['link3'])){ ?>
<div class="gallery-item design">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb galerryVideoCopy">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link3']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<p style="color: white"><?php echo $page_info[0]['link3_urdu']?></p>
<p style="color: white"><?php echo $page_info[0]['link3_hindi']?></p>
<p style="color: white"><?php echo $page_info[0]['link3_eng']?></p>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<script type="text/javascript">
$(function(){
$("#link1").on("play",function(){
$("#link2").trigger("pause");
$("#link3").trigger("pause");
});
$("#link2").on("play",function(){
$("#link1").trigger("pause");
$("#link3").trigger("pause");
});
$("#link3").on("play",function(){
$("#link1").trigger("pause");
$("#link2").trigger("pause");
});
});
</script>
I am trying like this but it's not working. I do not know where I am wrong in my code. Please give me some solution to this.