My website features a full-screen background video that plays upon loading, and I want the same video to play when a user clicks the play button to open a modal. However, my issue is that the modal video (iframe) starts playing in the background as soon as the page loads. This is not the desired behavior. I want the sequence to be: 1. Page loads with muted background video 2. User clicks play button 3. Modal opens and the video plays 4. Video stops when modal closes. I have tried using autoplay=0, which works when directing to a YouTube source video, but this particular video is located in my project folder.
<!-- banner -->
<section class="vid">
<div class="video-container">
<video class="bg-video" autoplay muted loop>
<source src="video/americandream.mp4" type="video/mp4">
Your browser does not support video playback.
</video>
</div>
<div class="container-fluid banner">
<div class="row">
<div class="col-lg-12 motto text-white">
<h1 class="banner-heading">
<span class="overlay-heading">We Believe <br> People Make<br> The Difference</span>
</h1>
<div class="d-flex align-items-center mt-4">
<a class="btn btn-primary btn-demo-top btn-wide demo mb-2 mr-md-2" href="demo.html">Book a Demo</a>
<a href="#" class="launch-modal media align-items-center u-media-player" data-modal-id="modal-video">
<span class="d-flex mr-2 ml-3">
<span class="u-media-player__icon u-media-player__icon--success">
<span class="fa fa-play u-media-player__icon-inner"></span>
</span>
</span>
<span class="media-body text-white u-media-player__icon--success">Play Video</span>
</a>
</div>
</div>
</div>
</div>
</section>
<!-- end of Banner -->
<!-- MODAL -->
<div class="modal fade" id="modal-video" tabindex="-1" role="dialog" aria-labelledby="modal-video-label">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="modal-video">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="video/americandream.mp4" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END MODAL -->