Good morning, I have a problem, I wanted to display a modal at the end of each video, the first video worked correctly, but in the second I can not ...
Follow the code below ...
If anyone can help, thank you very much!
var vid = document.getElementById("video_ctrl");
function playVid() {
myVideo.play();
}
document.getElementById('video_ctrl').addEventListener('ended',myHandler,false);
function myHandler(e) {
$('#myModal').modal('show');
}
document.getElementById('video_ctrl1').addEventListener('ended',myHandler,false);
function myHandler(e) {
$('#myModal1').modal('show');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div id="div_video">
<video autoplay id="video_ctrl" width="100%">
<source src="img/abertura.ogv" type="video/mp4" />
</video>
</div>
<script>
function setvideo(src) {
document.getElementById('div_video').innerHTML = '<video autoplay id="video_ctrl1" style="width: 100%;"><source src="' + src + '" type="video/mp4"></video>';
}
</script>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" onClick="setvideo('img/video2.mp4');" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="myModal1" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" onClick="setvideo('img/video2.mp4');" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>