Skip to content

Commit

Permalink
@imbcmdth Deferred the implementation of select functions in the tech…
Browse files Browse the repository at this point in the history
… to source handlers if they provide them. closes #2760
  • Loading branch information
jrivera authored and gkatsev committed Oct 30, 2015
1 parent d0efd16 commit 0b32893
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CHANGELOG
* @misteroneill Add browserify
* @brkattk updated emulateTextTrack to exit early if no textTracks ([view](https://github.com/videojs/video.js/pull/2426))
* @chemoish Fix captions sticking to bottom for webkit browsers. Fixes #2193 ([view](https://github.com/videojs/video.js/pull/2702))
* @imbcmdth Deferred the implementation of select functions in the tech to source handlers if they provide them ([view](https://github.com/videojs/video.js/pull/2760))

--------------------

Expand Down
29 changes: 21 additions & 8 deletions src/js/tech/tech.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,29 @@ Tech.withSourceHandlers = function(_Tech){
return '';
};

let originalSeekable = _Tech.prototype.seekable;
/*
* When using a source handler, prefer its implementation of
* any function normally provided by the tech.
*/
let deferrable = [
'seekable',
'duration'
];

// when a source handler is registered, prefer its implementation of
// seekable when present.
_Tech.prototype.seekable = function() {
if (this.sourceHandler_ && this.sourceHandler_.seekable) {
return this.sourceHandler_.seekable();
deferrable.forEach(function (fnName) {
let originalFn = this[fnName];

if (typeof originalFn !== 'function') {
return;
}
return originalSeekable.call(this);
};

this[fnName] = function() {
if (this.sourceHandler_ && this.sourceHandler_[fnName]) {
return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments);
}
return originalFn.apply(this, arguments);
};
}, _Tech.prototype);

/*
* Create a function for setting the source using a source object
Expand Down

0 comments on commit 0b32893

Please sign in to comment.