From f606f9df501f89ca7125b06a116fb583227e2de6 Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Wed, 13 Apr 2016 20:28:09 +0200 Subject: [PATCH] @nickygerritsen Pass tech options to source handlers. closes #3245 --- CHANGELOG.md | 2 +- src/js/tech/flash-rtmp.js | 7 ++++--- src/js/tech/flash.js | 7 ++++--- src/js/tech/html5.js | 7 ++++--- src/js/tech/tech.js | 2 +- test/unit/tech/tech.test.js | 7 ++++--- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ab56a5cd..33b31d753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ CHANGELOG ========= ## HEAD (Unreleased) -_(none)_ +* @nickygerritsen Pass tech options to source handlers ([view](https://github.com/videojs/video.js/pull/3245)) -------------------- diff --git a/src/js/tech/flash-rtmp.js b/src/js/tech/flash-rtmp.js index 0d9a83f15..ff1864822 100644 --- a/src/js/tech/flash-rtmp.js +++ b/src/js/tech/flash-rtmp.js @@ -95,10 +95,11 @@ function FlashRtmpDecorator(Flash) { * Pass the source to the flash object * Adaptive source handlers will have more complicated workflows before passing * video data to the video element - * @param {Object} source The source object - * @param {Flash} tech The instance of the Flash tech + * @param {Object} source The source object + * @param {Flash} tech The instance of the Flash tech + * @param {Object} options The options to pass to the source */ - Flash.rtmpSourceHandler.handleSource = function(source, tech){ + Flash.rtmpSourceHandler.handleSource = function(source, tech, options){ let srcParts = Flash.streamToParts(source.src); tech['setRtmpConnection'](srcParts.connection); diff --git a/src/js/tech/flash.js b/src/js/tech/flash.js index 8d6bcc0aa..c11d3cc06 100644 --- a/src/js/tech/flash.js +++ b/src/js/tech/flash.js @@ -397,10 +397,11 @@ Flash.nativeSourceHandler.canHandleSource = function(source){ * Adaptive source handlers will have more complicated workflows before passing * video data to the video element * - * @param {Object} source The source object - * @param {Flash} tech The instance of the Flash tech + * @param {Object} source The source object + * @param {Flash} tech The instance of the Flash tech + * @param {Object} options The options to pass to the source */ -Flash.nativeSourceHandler.handleSource = function(source, tech){ +Flash.nativeSourceHandler.handleSource = function(source, tech, options){ tech.setSrc(source.src); }; diff --git a/src/js/tech/html5.js b/src/js/tech/html5.js index e8bb1f9b5..4d89eb44a 100644 --- a/src/js/tech/html5.js +++ b/src/js/tech/html5.js @@ -903,10 +903,11 @@ Html5.nativeSourceHandler.canHandleSource = function(source){ * Adaptive source handlers will have more complicated workflows before passing * video data to the video element * - * @param {Object} source The source object - * @param {Html5} tech The instance of the Html5 tech + * @param {Object} source The source object + * @param {Html5} tech The instance of the Html5 tech + * @param {Object} options The options to pass to the source */ -Html5.nativeSourceHandler.handleSource = function(source, tech){ +Html5.nativeSourceHandler.handleSource = function(source, tech, options){ tech.setSrc(source.src); }; diff --git a/src/js/tech/tech.js b/src/js/tech/tech.js index 3f9a509a6..87354751d 100644 --- a/src/js/tech/tech.js +++ b/src/js/tech/tech.js @@ -714,7 +714,7 @@ Tech.withSourceHandlers = function(_Tech){ this.off('dispose', this.disposeSourceHandler); this.currentSource_ = source; - this.sourceHandler_ = sh.handleSource(source, this); + this.sourceHandler_ = sh.handleSource(source, this, this.options_); this.on('dispose', this.disposeSourceHandler); return this; diff --git a/test/unit/tech/tech.test.js b/test/unit/tech/tech.test.js index 8938b7d11..5eaad370c 100644 --- a/test/unit/tech/tech.test.js +++ b/test/unit/tech/tech.test.js @@ -147,9 +147,10 @@ test('should add the source handler interface to a tech', function(){ } return ''; }, - handleSource: function(s, t){ + handleSource: function(s, t, o){ strictEqual(tech, t, 'the tech instance was passed to the source handler'); strictEqual(sourceA, s, 'the tech instance was passed to the source handler'); + strictEqual(tech.options_, o, 'the tech options were passed to the source handler'); return new handlerInternalState(); } }; @@ -161,7 +162,7 @@ test('should add the source handler interface to a tech', function(){ canHandleSource: function(source){ return ''; // no support }, - handleSource: function(source, tech){ + handleSource: function(source, tech, options){ ok(false, 'handlerTwo supports nothing and should never be called'); } }; @@ -261,7 +262,7 @@ test('delegates seekable to the source handler', function(){ canHandleSource: function() { return true; }, - handleSource: function(source, tech) { + handleSource: function(source, tech, options) { return handler; } });