Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsHow to get my custom video play button to function?
Hello,
I am trying to create a custom video player. I am starting with getting the play button to work, but it is not. Does anyone know what steps I am missing in getting this to work?
HTML
<!--Embedded Video -->
<div id="video-container">
<video height="500" width="620" id="video1">
<source src="video/video2.ogg" type="video/ogg" class="video" />
<source src="video/video1.mp4" type="video/mp" class="video" />
<track label="English" id="captions" kind="subtitles" srclang="en" src="video/captions.vtt" default />
</video>
</div>
<!--Video Controls -->
<button type="button" id="play_pause"><img class="icon play" src="icons/pause- icon.png" alt="pause button"></button>
Javascript
``` //video variables
var video = document.getElementById("video1");
//button variables
var playButton = document.getElementById("play_pause");
var volume = document.getElementById("volume");
var fullScreen = document.getElementById("full_screen");
//progressbar variables
var seek = document.getElementById("seekBar");
var buffer = document.getElementById("bufferBar");
//event listeners
playButton.addEventListener("click", playPause, true);
window.onload = initializeVideo;
function playPause() {
if (video.paused === true){
video.play();
} else {
video.pause();
playButton.innerHTML = "<img src="icons/play-icon.png alt="playButton">"
}
}