From 4bfc0b9221734c75f305dbeefe8e49a9d73b766b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 28 Jun 2012 18:39:07 -0700 Subject: Relocating code I added the fix in the wrong location before, this is more proper, still needs to be moved to where the video element is created or added to the DOM (in this spot the event is added every time src is changed). --- js/controllers/elements/video-controller.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'js/controllers/elements/video-controller.js') diff --git a/js/controllers/elements/video-controller.js b/js/controllers/elements/video-controller.js index c36752f5..44ba5aa1 100755 --- a/js/controllers/elements/video-controller.js +++ b/js/controllers/elements/video-controller.js @@ -28,6 +28,19 @@ exports.VideoController = Montage.create(ElementController, { value: function(el, p, value) { switch(p) { case "src": + + //TODO: Move this to the location where the element is created + el.addEventListener('canplay', function(e) { + //TODO: Figure out why the video must be seeked to the end before pausing + var time = Math.ceil(this.duration); + //Trying to display the last frame (doing minus 2 seconds if long video) + if (time > 2) this.currentTime = time - 2; + else if (time > 1) this.currentTime = time - 1; + else this.currentTime = time || 0; + //Pauing video + this.pause(); + }, false); + el.setAttribute(p, value); break; case "poster": -- cgit v1.2.3