aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorJose Antonio Marquez Russo2012-06-28 22:50:24 -0700
committerJose Antonio Marquez Russo2012-06-28 22:50:24 -0700
commit7a8c1f20208fe09d78dc6ec5c8762cebcdf9b677 (patch)
treedd4478eea3294a7a41d150247b3eac8791acc1ee /js/tools
parent4bfc0b9221734c75f305dbeefe8e49a9d73b766b (diff)
parent1b6202d3cd517480aebafdfe97e9b89600d715ce (diff)
downloadninja-7a8c1f20208fe09d78dc6ec5c8762cebcdf9b677.tar.gz
Merge pull request #40 from mencio/video-fix
Video fix cleanup
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