From 1b6202d3cd517480aebafdfe97e9b89600d715ce Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 28 Jun 2012 22:46:07 -0700 Subject: video autopsy fix: moving the event handler on creation Signed-off-by: Valerio Virgillito --- js/tools/TagTool.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index 31918f92..27665ee6 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -86,11 +86,15 @@ exports.TagTool = Montage.create(DrawingTool, { // Create the element if(this.options.selectedElement === "custom") { element = document.application.njUtils.make(this.options.customName.value, null, this.application.ninja.currentDocument); - } else { element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument); } + // Adding a canplay event to videos to pause them and prevent autoplay on stage + if(this.options.selectedElement === "video") { + element.addEventListener("canplay", this, false); + } + // Create the styles styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); @@ -109,6 +113,24 @@ exports.TagTool = Montage.create(DrawingTool, { // Add the element and styles this.application.ninja.elementMediator.addElements(element, styles); } + }, + + handleCanplay: { + value: function(event) { + //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 + event.target.pause(); + } } + }); -- cgit v1.2.3 From 54f95bf52f660f5d8bcb3180c203ffd6ce9b8557 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 28 Jun 2012 23:27:38 -0700 Subject: Fixing reference to object --- js/tools/TagTool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/tools') diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index 27665ee6..80e6150d 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -118,14 +118,14 @@ exports.TagTool = Montage.create(DrawingTool, { handleCanplay: { value: function(event) { //TODO: Figure out why the video must be seeked to the end before pausing - var time = Math.ceil(this.duration); + var time = Math.ceil(event.target.duration); //Trying to display the last frame (doing minus 2 seconds if long video) if (time > 2) { - this.currentTime = time - 2; + event.target.currentTime = time - 2; } else if (time > 1) { - this.currentTime = time - 1; + event.target.currentTime = time - 1; } else { - this.currentTime = time || 0; + event.target.currentTime = time || 0; } //Pauing video event.target.pause(); -- cgit v1.2.3