The #play-pause should change the src attribute. I've tried to use innerHtml but I can't input value like '/media/pauseButton.png" />'
var video = document.getElementById("postvideo");
var playButton = document.getElementById("play-pause");
// Event listener for the play/pause button
playButton.addEventListener("click", function() {
if (video.paused == true) {
// Play the video
video.play();
// Update the button to 'Pause'
playButton.innerHTML = "<img src="<?php echo get_template_directory_uri(); ?>/media/playButton.png" />";
} else {
// Pause the video
video.pause();
// Update the button to 'Play'
playButton.innerHTML = "<img src="<?php echo get_template_directory_uri(); ?>/media/pauseButton.png" />";
}
After refreshing, The #play-pause isn't changing and the function to video.pause(); no longer works.
What I want it to do is change the image source path to change from the play icon image to the pause icon image. Here is the initial output of the layout html on document ready:
<div id="play-pause">
<img src="<?php echo get_template_directory_uri(); ?>/media/playButton.png" />
</div>
'after thesrcon that line.playButton.innerHTML = "<img src='<?php echo get_template_directory_uri(); ?>/media/playButton.png' />";