aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-28 22:46:07 -0700
committerValerio Virgillito2012-06-28 22:46:07 -0700
commit1b6202d3cd517480aebafdfe97e9b89600d715ce (patch)
treedd4478eea3294a7a41d150247b3eac8791acc1ee /js/tools
parent35af74aa558a642af8bcdbd8c18098b94771537d (diff)
downloadninja-1b6202d3cd517480aebafdfe97e9b89600d715ce.tar.gz
video autopsy fix: moving the event handler on creation
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/TagTool.js24
1 files changed, 23 insertions, 1 deletions
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, {
86 // Create the element 86 // Create the element
87 if(this.options.selectedElement === "custom") { 87 if(this.options.selectedElement === "custom") {
88 element = document.application.njUtils.make(this.options.customName.value, null, this.application.ninja.currentDocument); 88 element = document.application.njUtils.make(this.options.customName.value, null, this.application.ninja.currentDocument);
89
90 } else { 89 } else {
91 element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument); 90 element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument);
92 } 91 }
93 92
93 // Adding a canplay event to videos to pause them and prevent autoplay on stage
94 if(this.options.selectedElement === "video") {
95 element.addEventListener("canplay", this, false);
96 }
97
94 // Create the styles 98 // Create the styles
95 styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); 99 styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData);
96 100
@@ -109,6 +113,24 @@ exports.TagTool = Montage.create(DrawingTool, {
109 // Add the element and styles 113 // Add the element and styles
110 this.application.ninja.elementMediator.addElements(element, styles); 114 this.application.ninja.elementMediator.addElements(element, styles);
111 } 115 }
116 },
117
118 handleCanplay: {
119 value: function(event) {
120 //TODO: Figure out why the video must be seeked to the end before pausing
121 var time = Math.ceil(this.duration);
122 //Trying to display the last frame (doing minus 2 seconds if long video)
123 if (time > 2) {
124 this.currentTime = time - 2;
125 } else if (time > 1) {
126 this.currentTime = time - 1;
127 } else {
128 this.currentTime = time || 0;
129 }
130 //Pauing video
131 event.target.pause();
132 }
112 } 133 }
134
113}); 135});
114 136