From a859432f0cc5746e2855c16565a75391ea657772 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 28 Jun 2012 18:17:22 -0700 Subject: Fixing video autoplay bug in PI Adding functionality to prevent autoplay on videos while in author-time. Fixes chrome preview issues. --- .../tools-properties/tag-properties.reel/tag-properties.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'js') diff --git a/js/components/tools-properties/tag-properties.reel/tag-properties.js b/js/components/tools-properties/tag-properties.reel/tag-properties.js index ab745049..f14183e0 100755 --- a/js/components/tools-properties/tag-properties.reel/tag-properties.js +++ b/js/components/tools-properties/tag-properties.reel/tag-properties.js @@ -54,6 +54,7 @@ var TagProperties = exports.TagProperties = Montage.create(ToolProperties, { this.divElement.addEventListener("click", this, false); this.imageElement.addEventListener("click", this, false); this.videoElement.addEventListener("click", this, false); + this.videoElement.addEventListener("canplay", this, false); this.canvasElement.addEventListener("click", this, false); this.customElement.addEventListener("click", this, false); } @@ -99,6 +100,19 @@ var TagProperties = exports.TagProperties = Montage.create(ToolProperties, { } } }, + + handleCanplay: { + value: 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(); + } + }, _selectedElement: { value: "div", enumerable: false -- cgit v1.2.3