1
0
mirror of https://github.com/videojs/video.js.git synced 2024-11-24 08:42:25 +02:00

@imbcmdth Deferred the implementation of select functions in the tech to source handlers if they provide them. closes #2760

This commit is contained in:
jrivera 2015-10-30 16:09:27 -04:00 committed by Gary Katsevman
parent d0efd16b49
commit 0b32893612
2 changed files with 22 additions and 8 deletions

View File

@ -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))
--------------------

View File

@ -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