-
Notifications
You must be signed in to change notification settings - Fork 425
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
add back manual smooth quality changes via smoothQualityChange flag #235
Conversation
63da8cd
to
f808169
Compare
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` |
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.
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)
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.
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.
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.
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
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.
Yep, covers all bases nicely.
src/rendition-mixin.js
Outdated
.fastQualityChange_ | ||
.bind(hlsHandler.masterPlaylistController_); | ||
// Get a reference to a bound version of the quality change function | ||
let qualityChangeFunction = (hlsHandler.options_.smoothQualityChange ? |
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.
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);
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.
Dang, that's much saner. Thanks for the suggestion.
test/configuration.test.js
Outdated
@@ -28,6 +28,11 @@ const options = [{ | |||
default: 4194304, | |||
test: 5, | |||
alt: 555 | |||
}, { | |||
name: 'smoothQualityChange', | |||
default: undefined, |
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.
should the default be false
instead of undefined
?
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.
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
?
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.
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.
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.
Yup, fair enough, explicit is always good.
src/videojs-http-streaming.js
Outdated
@@ -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; |
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.
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
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.
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.
test/configuration.test.js
Outdated
@@ -28,6 +28,11 @@ const options = [{ | |||
default: 4194304, | |||
test: 5, | |||
alt: 555 | |||
}, { | |||
name: 'smoothQualityChange', | |||
default: undefined, |
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.
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.
391a66c
to
2e401a8
Compare
Made the review changes, thanks for the great comments!! let me know if you think README blob is sufficient. |
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, I haven't been able to manually test this though
2e401a8
to
9219955
Compare
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. |
Congrats on merging your first pull request! 🎉🎉🎉 |
Description
#113 unfortunately completely removed smooth quality switching for manual quality switches. This PR adds it back via a configuration option.
Specific Changes proposed
smoothQualityChange
config optionfastQualityChange
orsmoothQualityChange
using a ternary that checks the aforementioned config optionRequirements Checklist