0

I'm pretty new to bootstrap and I can't seem to find a answer to my question. I am playing a local video in my website embedded using the video tag.I need to use some javascript to stop the video playing when I exit the modal. Just can't get any of my solutions to work - I have tried adopting the iFrame solution.

<div class="modal fade" id="videoModal">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header1">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">What can Minecraft do for your class!</h4>
                </div>
                <div class="modal-body">
                <div class="embed-responsive embed-responsive-16by9">
                    <video id="my_video_1" class="video-js vjs-default-skin embed-responsive-item" controls preload="auto"  data-setup="{}"> 
                        <source src="videos/Minecraft greenscree.mp4" type='video/mp4'> 
                    </video>
                    </div>
                </div>
            </div>
        </div>
    </div> 

1 Answers1

0

You can hook in to the modal's hide event, and then stop the video.

Like so:

$('#viewModal').on('hide.bs-modal', function(e) {
    $('#my_view_1').trigger('pause');
});
Ted A.
  • 2,264
  • 17
  • 22