I'm using the "plyr.js" video player script. All works perfectly when I open the page on its own, but when I load it inside a div of another (i.e. when I load video.html inside a div of my index.html), the function stops working...
Any idea on how to solve it?
This is the code:
<link rel='stylesheet' href='https://cdn.plyr.io/3.4.6/plyr.css'>
<video class="video-fluid" id="player" poster="fotos/demo1.jpg" playsinline autoplay loop>
<source src="demo1.mp4" type="video/mp4">
</video>
<button type="button" class="btn js-stop" id="stop">Stop</button>
<script src='https://cdn.plyr.io/3.4.6/plyr.js'></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
controls = [];
player = new Plyr('#player', { controls });
window.player = player;
});
$("#stop").click(function(){
player.stop();
});
</script>
As I mentioned, the code on its own works perfectly, but when I load it inside a div of another page with a .load("video.html"), the stop button no longer works.
Thanks in advance!