I am using Javascript to make a video player that plays a video. All the codes seem to be added right. But the code does not seem to work. Here it is:
HTML
<video id="myVideo">
<source src="coolfirst2hours.mp4" type="video/mp4">
</video>
<button id="playVid" type="button">PLAY</button>
Javascript
// Get the video and play button elements
const videoElem = document.getElementById('myVideo');
const playButton = document.getElementById('playVid');
// Add event listener to play button
playButton.addEventListener('click', () => {
videoElem.play();
});