Skip to content

Commit

Permalink
refactor: player.techGet_() (#4687)
Browse files Browse the repository at this point in the history
  • Loading branch information
kocoten1992 authored and gkatsev committed Oct 31, 2017
1 parent cde8335 commit a1748aa
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down

0 comments on commit a1748aa

Please sign in to comment.