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

add back manual smooth quality changes via smoothQualityChange flag #235

Merged
merged 1 commit into from
Oct 22, 2018

Conversation

squarebracket
Copy link
Contributor

Description

#113 unfortunately completely removed smooth quality switching for manual quality switches. This PR adds it back via a configuration option.

Specific Changes proposed

  • Add smoothQualityChange config option
  • Merge it with a possible source option of the same name
  • Select fastQualityChange or smoothQualityChange using a ternary that checks the aforementioned config option

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
  • Reviewed by Two Core Contributors

@squarebracket squarebracket force-pushed the smooth-quality-switch-flag branch 3 times, most recently from 63da8cd to f808169 Compare September 19, 2018 15:06
README.md Outdated
switches, but will cause quality switches to only be visible after a few
seconds.

Note that this _only_ affects quality changes triggered via the `qualityLevels`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qualityLevels is technically an api added by a separate plugin. It would probably be good to also mention the representations api (you can even add an anchor link to the relevant section of the readme #hlsrepresentations)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was wondering about this myself since it's the representations API from the point of view of VHS, but the qualityLevels API from the point of view of the programmer. I will do as you suggest.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, but ONLY if the quality levels plugin is included, which is optional. Manual rendition selection is still possible from the programmer point of view using the representations API. I suggested linking to the readme section since it mentions both the quality levels api (recommended approach) and the representations api

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, covers all bases nicely.

.fastQualityChange_
.bind(hlsHandler.masterPlaylistController_);
// Get a reference to a bound version of the quality change function
let qualityChangeFunction = (hlsHandler.options_.smoothQualityChange ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally not a fan of large or multi line ternaries, but feel free to ignore this suggestion as its just my preference.

const {
  masterPlaylistController_: mpc,
  options_: { smoothQualityChange }
} = hlsHandler;
const changeType = smoothQualityChange ? 'smooth' : 'fast';
const qualityChangeFunction = mpc[`${changeType}QualityChange_`].bind(mpc);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang, that's much saner. Thanks for the suggestion.

@@ -28,6 +28,11 @@ const options = [{
default: 4194304,
test: 5,
alt: 555
}, {
name: 'smoothQualityChange',
default: undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the default be false instead of undefined?

Copy link
Contributor Author

@squarebracket squarebracket Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. Technically speaking, I don't set the default value to false, I just let it be undefined if it's not defined in the options. So I chose undefined here since that's what the default would be in absence of an explicit value. Do you think I should explicitly set the option to be false if a value isn't given, or just change the default here in the test to be false?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to set it to false if not set like we do with withCredentials here The explicit setting of the false default should be done here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, fair enough, explicit is always good.

@@ -384,6 +384,9 @@ class HlsHandler extends Component {
this.tech_.setCurrentTime(time);
this.setCurrentTime(time);
};
if (this.source_.smoothQualityChange !== undefined) {
this.options_.smoothQualityChange = this.source_.smoothQualityChange;
Copy link
Contributor

@mjneil mjneil Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to also be a source level option, or just a player level option?
If source level option is also valid, you should add smoothQualityChange to here instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes thanks, in an older version I was setting the quality change function hereish which required the MPC, and thus couldn't go in setOptions. But it can now, great catch.

@@ -28,6 +28,11 @@ const options = [{
default: 4194304,
test: 5,
alt: 555
}, {
name: 'smoothQualityChange',
default: undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to set it to false if not set like we do with withCredentials here The explicit setting of the false default should be done here as well.

@squarebracket
Copy link
Contributor Author

Made the review changes, thanks for the great comments!! let me know if you think README blob is sufficient.

mjneil
mjneil previously approved these changes Sep 19, 2018
Copy link
Contributor

@mjneil mjneil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I haven't been able to manually test this though

@squarebracket
Copy link
Contributor Author

squarebracket commented Oct 17, 2018

Rebased to master and squashed into a single commit. Unfortunately, it looks like the rebase+squash undid @mjneil's approval. I tested the code post-rebase/squash and it's working as expected.

@gesinger gesinger merged commit 0e4fdf9 into videojs:master Oct 22, 2018
@welcome
Copy link

welcome bot commented Oct 22, 2018

Congrats on merging your first pull request! 🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants