From 10c8a4a45b2af2694591abf81c450e2633b8dcf3 Mon Sep 17 00:00:00 2001 From: David LaPalomento Date: Wed, 15 Jul 2015 14:18:23 -0400 Subject: [PATCH 1/3] Fire "seeking" from the Flash tech SWF code is still hard to validate so move the logic to fire "seeking" into the js portion of the Flash tech. --- src/js/tech/flash.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/js/tech/flash.js b/src/js/tech/flash.js index c23bb05531..042f2639c1 100644 --- a/src/js/tech/flash.js +++ b/src/js/tech/flash.js @@ -54,6 +54,10 @@ class Flash extends Tech { window.videojs.Flash.onReady = Flash.onReady; window.videojs.Flash.onEvent = Flash.onEvent; window.videojs.Flash.onError = Flash.onError; + + this.on('seeked', function() { + this.lastSeekTarget_ = undefined; + }); } /** @@ -157,6 +161,14 @@ class Flash extends Tech { } } + /** + * Returns true if the tech is currently seeking. + * @return {boolean} true if seeking + */ + seeking() { + return this.lastSeekTarget_ !== undefined; + } + /** * Set current time * @@ -171,6 +183,7 @@ class Flash extends Tech { time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1); this.lastSeekTarget_ = time; + this.trigger('seeking'); this.el_.vjs_setProperty('currentTime', time); super.setCurrentTime(); } @@ -284,7 +297,7 @@ class Flash extends Tech { // Create setters and getters for attributes const _api = Flash.prototype; const _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(','); -const _readOnly = 'error,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(','); +const _readOnly = 'error,networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(','); function _createSetter(attr){ var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1); From 7cc13cfeea95dbb5a784bfbb2ce72628292323d6 Mon Sep 17 00:00:00 2001 From: David LaPalomento Date: Tue, 21 Jul 2015 14:48:17 -0400 Subject: [PATCH 2/3] Update to video-js-swf 5.0.0-rc0 Stop firing seeking in the SWF itself. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6e82f09844..d766095936 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "safe-json-parse": "^4.0.0", "videojs-font": "1.3.0", "videojs-ie8": "1.1.0", - "videojs-swf": "4.7.1", + "videojs-swf": "5.0.0-rc0", "vtt.js": "git+https://github.com/gkatsev/vtt.js.git#vjs-v0.12.1" }, "devDependencies": { From 9983434e5299a9b54ceb66c231bc7bdfee4bf1de Mon Sep 17 00:00:00 2001 From: David LaPalomento Date: Tue, 21 Jul 2015 14:56:21 -0400 Subject: [PATCH 3/3] Fix Flash currentTime test Add a trigger() to the mock Flash implementation and verify that "seeking" is fired the appropriate number of times. --- test/unit/tech/flash.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unit/tech/flash.test.js b/test/unit/tech/flash.test.js index 085d6c514c..570e5d1f9e 100644 --- a/test/unit/tech/flash.test.js +++ b/test/unit/tech/flash.test.js @@ -23,6 +23,7 @@ test('Flash.canPlaySource', function() { test('currentTime', function() { let getCurrentTime = Flash.prototype.currentTime; let setCurrentTime = Flash.prototype.setCurrentTime; + let seekingCount = 0; let seeking = false; let setPropVal; let getPropVal; @@ -41,6 +42,11 @@ test('currentTime', function() { seekable(){ return createTimeRange(5, 1000); }, + trigger(event){ + if (event === 'seeking') { + seekingCount++; + } + }, seeking(){ return seeking; } @@ -54,6 +60,7 @@ test('currentTime', function() { // Test the currentTime setter setCurrentTime.call(mockFlash, 10); equal(setPropVal, 10, 'currentTime is set on the swf element'); + equal(seekingCount, 1, 'triggered seeking'); // Test current time while seeking setCurrentTime.call(mockFlash, 20); @@ -61,15 +68,18 @@ test('currentTime', function() { result = getCurrentTime.call(mockFlash); equal(result, 20, 'currentTime is retrieved from the lastSeekTarget while seeking'); notEqual(result, getPropVal, 'currentTime is not retrieved from the element while seeking'); + equal(seekingCount, 2, 'triggered seeking'); // clamp seeks to seekable setCurrentTime.call(mockFlash, 1001); result = getCurrentTime.call(mockFlash); equal(result, mockFlash.seekable().end(0), 'clamped to the seekable end'); + equal(seekingCount, 3, 'triggered seeking'); setCurrentTime.call(mockFlash, 1); result = getCurrentTime.call(mockFlash); equal(result, mockFlash.seekable().start(0), 'clamped to the seekable start'); + equal(seekingCount, 4, 'triggered seeking'); }); test('dispose removes the object element even before ready fires', function() {