aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-29 16:33:44 -0700
committerValerio Virgillito2012-06-29 16:33:44 -0700
commit6616a13579109f2998d02ae65f7fa6b64105b68c (patch)
tree3f2b33aa7e82ba751c240e2ead1032ca4eeed031 /js/tools
parentccd9dd85d39b338c19d51e34b446b126061b07fb (diff)
parent435de0e8fae1e29e5203300704575ae285739191 (diff)
downloadninja-6616a13579109f2998d02ae65f7fa6b64105b68c.tar.gz
Merge pull request #360 from joseeight/Document
Adding fix to prevent video from playing
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..80e6150d 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(event.target.duration);
122 //Trying to display the last frame (doing minus 2 seconds if long video)
123 if (time > 2) {
124 event.target.currentTime = time - 2;
125 } else if (time > 1) {
126 event.target.currentTime = time - 1;
127 } else {
128 event.target.currentTime = time || 0;
129 }
130 //Pauing video
131 event.target.pause();
132 }
112 } 133 }
134
113}); 135});
114 136