Skip to content
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

Merged
merged 1 commit into from
Mar 4, 2022
Merged

Conversation

lindapaiste
Copy link
Contributor

Just some minor code clean-up 🧹 No changes to logic.

  • Add JSDoc types to existing Video class.
  • 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.

* 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.
@joeyklee joeyklee added the SEMVER/patch a version tag for a patch release change label Mar 4, 2022
return new Promise((resolve, reject) => {
if (!this.videoElt) {
reject(new Error('No video was passed to the constructor.'));
}
Copy link
Contributor

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;
Copy link
Contributor

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. 👍

Copy link
Contributor

@joeyklee joeyklee left a 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!

@joeyklee
Copy link
Contributor

joeyklee commented Mar 4, 2022

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 🙈

@joeyklee joeyklee merged commit d01fe31 into ml5js:main Mar 4, 2022
@joeyklee
Copy link
Contributor

joeyklee commented Mar 4, 2022

@all-contributors please add @lindapaiste for code ideas bug

@allcontributors
Copy link
Contributor

@joeyklee

I've put up a pull request to add @lindapaiste! 🎉

@lindapaiste lindapaiste deleted the cleanup/video-class branch May 9, 2022 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SEMVER/patch a version tag for a patch release change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants