-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
feat: Add audioPosterMode option #7629
feat: Add audioPosterMode option #7629
Conversation
💖 Thanks for opening this pull request! 💖 Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
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.
Looks great, overall! Some thoughts and suggestions follow...
Either as part of this PR or as a followup, we should consider implementing |
@mister-ben Yeah, we should address that, but let's do it in a separate PR. |
Codecov Report
@@ Coverage Diff @@
## main #7629 +/- ##
==========================================
+ Coverage 80.24% 80.27% +0.03%
==========================================
Files 116 116
Lines 7325 7337 +12
Branches 1771 1774 +3
==========================================
+ Hits 5878 5890 +12
Misses 1447 1447
Continue to review full report at Codecov.
|
We should have some documentation in docs/guides/options.md until docs are moved elsewhere, otherwise looks good. |
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.
Works as expected and the implementation is pretty simple which is great 👍🏻
this.options_.audioPosterMode = value; | ||
|
||
if (this.options_.audioPosterMode) { | ||
this.tech_.hide(); |
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.
thought: hiding the tech explicitly could potentially cause playback issues, particularly with other techs like youtube. Though, I'm not positive. Probably not worth handling now, but might need another solution if we do run into such a problem in the future.
src/js/player.js
Outdated
value = value && Boolean(value); | ||
|
||
if (value === undefined || value === this.options_.audioPosterMode) { | ||
return this.options_.audioPosterMode; | ||
} |
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.
if value
is falsey, this will maintain value as that value, for example "" || Boolean("")
will return ""
rather than false
.
Might be better to do a type check below. Something like
value = value && Boolean(value); | |
if (value === undefined || value === this.options_.audioPosterMode) { | |
return this.options_.audioPosterMode; | |
} | |
value = value && Boolean(value); | |
if (typeof value === 'undefined' || typeof value !== "boolean" || value === this.options_.audioPosterMode) { | |
return this.options_.audioPosterMode; | |
} | |
src/js/player.js
Outdated
return this.options_.audioPosterMode; | ||
} | ||
|
||
this.options_.audioPosterMode = value; |
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.
Rather than storing and modifying the audioPosterMode
state on the options_
object itself, it might be preferable to create a new flag this.audioPosterMode_
. That way this.options_.audioPosterMode
always returns the option value set at initialization, and this.audioPosterMode_
returns the current state
src/js/player.js
Outdated
value = value && Boolean(value); | ||
|
||
if (value === undefined || typeof value !== 'boolean' || value === this.audioPosterMode_) { |
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 given this if
statement, we don't need to cast to boolean at all, right? And we shouldn't need the value === undefined
condition either, right?
Congrats on merging your first pull request! 🎉🎉🎉 |
Description
Adds audioPosterMode option that is false by default. Turning the audioPosterMode on will enable the Poster Viewer experience by hiding the video element and persistently displaying the poster image. If no poster is defined, the video player will be black.