From 02949f5b916d1bdfcb1031e94d622fbf821658c9 Mon Sep 17 00:00:00 2001 From: Steve Heffernan Date: Mon, 14 Jul 2014 15:46:17 -0700 Subject: [PATCH] Allow overriding flash methods that were previously hidden by creating them in init --- src/js/media/flash.js | 31 +++++++++++++++---------------- test/unit/flash.js | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/js/media/flash.js b/src/js/media/flash.js index 7b9dd7053..76f179154 100644 --- a/src/js/media/flash.js +++ b/src/js/media/flash.js @@ -60,9 +60,7 @@ vjs.Flash = vjs.MediaTechController.extend({ 'id': objId, 'name': objId, // Both ID and Name needed or swf to identifty itself 'class': 'vjs-tech' - }, options['attributes']), - - lastSeekTarget + }, options['attributes']) ; // If source was supplied pass as a flash var. @@ -77,19 +75,6 @@ vjs.Flash = vjs.MediaTechController.extend({ } } - this['setCurrentTime'] = function(time){ - lastSeekTarget = time; - this.el_.vjs_setProperty('currentTime', time); - }; - this['currentTime'] = function(time){ - // when seeking make the reported time keep up with the requested time - // by reading the time we're seeking to - if (this.seeking()) { - return lastSeekTarget; - } - return this.el_.vjs_getProperty('currentTime'); - }; - // Add placeholder to player div vjs.insertFirst(placeHolder, parentEl); @@ -284,6 +269,20 @@ vjs.Flash.prototype.src = function(src){ } }; +vjs.Flash.prototype.setCurrentTime = function(time){ + this.lastSeekTarget_ = time; + this.el_.vjs_setProperty('currentTime', time); +}; + +vjs.Flash.prototype.currentTime = function(time){ + // when seeking make the reported time keep up with the requested time + // by reading the time we're seeking to + if (this.seeking()) { + return this.lastSeekTarget_ || 0; + } + return this.el_.vjs_getProperty('currentTime'); +}; + vjs.Flash.prototype.currentSrc = function(){ var src = this.el_.vjs_getProperty('currentSrc'); // no src, check and see if RTMP diff --git a/test/unit/flash.js b/test/unit/flash.js index 982ef1b24..7062680b0 100644 --- a/test/unit/flash.js +++ b/test/unit/flash.js @@ -92,7 +92,7 @@ test('currentTime is the seek target during seeking', function() { currentTime = 3; strictEqual(3, tech.currentTime(), 'currentTime is retreived from the SWF'); - tech['setCurrentTime'](7); + tech.setCurrentTime(7); seeking = true; strictEqual(7, tech.currentTime(), 'during seeks the target time is returned'); });