jeudi 6 mars 2014

Trying to pause video at certain time


Vote count:

0




DISCLAIMER: I know basically nothing about code but have been tasked to do some in my spare time at work. I'm trying to use Edge Animate to create a 'choose your own ending' video. I apologize if this is the wrong forum for this question.


So I have a video that I need to play for a certain length of time, for our purposes let's call it 4 seconds. And then have some options come up on screen for the viewer to choose where they would like to go to in the video next. As I have no experience with this I can't even get the video to pause when I want. That's my first step. I will work on the second part of the project (making clickable items appear and designating their function) after I get this figured out.


Here is the code I have. I found it on a different post on here (Javascript event listener to start video at certain time and stop video after certain duration) The page/player work but it doesn't pause at the desired time. Any answers or redirect to somewhere that can help me would be much appreciated, Thanks!



var video = sym.$("rectangle");
$(video).html('<video poster="assets/poster.jpg" controls="controls"><source id="video1" src="assets/name-of-my-video.mp4" type="video/mp4"></video>');


function pauseVideo() {
var endtime = 4; // stop at 4 seconds

var video = document.getElementById('video1');

//handler should be bound first
video.addEventListener("timeupdate", function() {
if (this.currentTime >= endtime) {
this.pause();
}
}, false);

//suppose that video src has been already set properly
video.load();
video.play(); //must call this otherwise can't seek on some browsers, e.g. Firefox 4
try {
video.currentTime = starttime;
} catch (ex) {
//handle exceptions here
}
}


asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire