For my university work I have to make video controls and I'm trying to implement a play/pause button to start with but it doesn't work. Here is my code:
HTML:
<script src="Scripts/VideoScript.js"></script>
<section id="Example_Video_Container">
<video width = 576 height = 432 id = "Example_Video">
<source src="Videos/Example_Video.mp4">
<source src="Videos/Example_Video.webm">
</video>
<div id="Example_Video_Controls">
<button type="button" id="Play_Pause" >Play</button>
</div>
</section>
JavaScript:
window.addEventListener (“DOMContentLoaded”,handleWindowLoad)
function handleWindowLoad ()
{
var Video = document.getElementById ( "Example_Video" );
var PlayButton = document.getElementById ( "Play_Pause" );
var MuteButton = document.getElementById ( "Mute_Unmute" );
var Slider = document.getElementById ( "Slider" );
PlayButton.addEventListener ( "click", Play_Pause_Video ) ;
function Play_Pause_Video ()
{
if (Video.paused === true)
{
Video.play();
PlayButton.innerHTML = "Pause";
}
else
{
Video.pause();
PlayButton.innerHTML = "Play";
}
}
}
I have checked my file paths too, they should be all ok.