I\'m trying to place a video that autoplays without controls but I want to add three custom buttons below the video, each button jumps the video to a specific time. Not usin
You can set the currentTime
attribute of a video. Using your example:
var vidLinks = document.querySelectorAll('.navBtns a');
for(var i = 0, l = vidLinks.length; ++i){
makeVideoLink(vidLinks[i]);
}
function jumpToTime(time){
v.currentTime = time;
}
function makeVideoLink(element){
// Extract the `t=` hash from the link
var timestamp = element.hash.match(/\d+$/,'')[0] * 1000;
element.addEventListener('click', function videoLinkClick(e){
jumpToTime(timestamp);
return false;
},false)
}
Mozilla's Developer Network site has a great list of HTML5 media element properties.
Your links feature two different problems:
To control a video on a page directly without leaving the page, you'll need some javascript. Here you'll find an example how this will work.
JS Fiddle: Video CurrentTime Example
You'll need a function to jump to the specific time on click of one of your links, that would be (for instance):
var firstlink = document.getElementByTagName('a')[0];
firstlink.addEventListener("click", function (event) {
event.preventDefault();
myvideo.currentTime = 7;
myvideo.play();
}, false);