-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code clean-up: Video class. #1311
Conversation
* Add `typeof HTMLVideoElement !== 'undefined'` check to prevent errors in Node.js environments. * Reject `loadVideo` promise if there is no video. * Check that `this.size` is a non-zero number before using it. * Set `this.videoReady` to `true` from the base class.
return new Promise((resolve, reject) => { | ||
if (!this.videoElt) { | ||
reject(new Error('No video was passed to the constructor.')); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Positive affirmation:
- nice error catching up here! TY! 🙌
this.video.autoplay = true; | ||
this.video.playsinline = true; | ||
this.video.muted = true; | ||
const playPromise = this.video.play(); | ||
if (playPromise !== undefined) { | ||
playPromise.then(() => { | ||
this.videoReady = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Positive affirmation:
- nice one! This is def the right place to update the
this.videoReady
flag. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Excellent updates here!
I will merge this in -- the only models currently using this is StyleTransfer. Currently as far as I can tell the style transfer demos are broken, but this doesn't seem to be related to these changes 🙈 |
@all-contributors please add @lindapaiste for code ideas bug |
I've put up a pull request to add @lindapaiste! 🎉 |
Just some minor code clean-up 🧹 No changes to logic.
Video
class.typeof HTMLVideoElement !== 'undefined'
check to prevent errors in Node.js environments.loadVideo
promise if there is no video.this.size
is a non-zero number before using it.this.videoReady
totrue
from the base class.