1
I’m using Bootstrap 4 in a project with Vue;
In modal, I have a video on a Youtube iframe;
What I need to do is pause this video, when I close the modal, either by pressing the key Esc, or closing in the x
modal or clicking outside the modal to close it.
Does anyone have any idea what function I can perform to pause this video?
Note: I am not using jQuery.
Edit: This modal is inside a Vue component, so I believe that jQuery will not work.
Follows code:
Modal:
<!-- Modal Vídeo-->
<div class="modal fade" id="ModalVideo" tabindex="-1" role="dialog" aria-labelledby="ModalVideoLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content content_modal">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<div class="corpo_video">
<iframe width="100%" height="450px"
:src="'https://www.youtube.com/embed/'+texto[0].video">
</iframe>
</div>
</div>
</div>
</div>
Knob:
<div class="company__box pop" data-toggle="modal" data-target="#ModalVideo">
<span>
Assista ao nosso
vídeo institucional
</span>
</div>
Wouldn’t it just be adding a click function on the close button? Type
@click="minhaFuncaoPause()"
– Marconi
Use the API of Youtube, otherwise you will not be able to control the player within an iframe.
– Valdeir Psr
Example: https://jsfiddle.net/3s1jwx5g/
– Valdeir Psr
I don’t understand how you’re using BS4 without jQuery.
– Sam