Permalink
Browse files

refactor: player.techGet_() (#4687)

  • Loading branch information...
kocoten1992 authored and gkatsev committed Oct 31, 2017
1 parent cde8335 commit a1748aa590ad7c0eb2a8fa507b39dfff1cffc1e0
Showing with 26 additions and 22 deletions.
  1. +26 −22 src/js/player.js
View
@@ -1587,34 +1587,38 @@ class Player extends Component {
* @private
*/
techGet_(method) {
if (this.tech_ && this.tech_.isReady_) {
if (!this.tech_ || !this.tech_.isReady_) {
return;
}
if (method in middleware.allowedGetters) {
return middleware.get(this.middleware_, this.tech_, method);
}
if (method in middleware.allowedGetters) {
return middleware.get(this.middleware_, this.tech_, method);
// Flash likes to die and reload when you hide or reposition it.
// In these cases the object methods go away and we get errors.
// When that happens we'll catch the errors and inform tech that it's not ready any more.
try {
return this.tech_[method]();
} catch (e) {
// When building additional tech libs, an expected method may not be defined yet
if (this.tech_[method] === undefined) {
log(`Video.js: ${method} method not defined for ${this.techName_} playback technology.`, e);
throw e;
}
// Flash likes to die and reload when you hide or reposition it.
// In these cases the object methods go away and we get errors.
// When that happens we'll catch the errors and inform tech that it's not ready any more.
try {
return this.tech_[method]();
} catch (e) {
// When building additional tech libs, an expected method may not be defined yet
if (this.tech_[method] === undefined) {
log(`Video.js: ${method} method not defined for ${this.techName_} playback technology.`, e);
// When a method isn't available on the object it throws a TypeError
} else if (e.name === 'TypeError') {
log(`Video.js: ${method} unavailable on ${this.techName_} playback technology element.`, e);
this.tech_.isReady_ = false;
} else {
log(e);
}
// When a method isn't available on the object it throws a TypeError
if (e.name === 'TypeError') {
log(`Video.js: ${method} unavailable on ${this.techName_} playback technology element.`, e);
this.tech_.isReady_ = false;
throw e;
}
}
return;
// If error unknown, just log and throw
log(e);
throw e;
}
}
/**

0 comments on commit a1748aa

Please sign in to comment.