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

feat: Add audioPosterMode option #7629

Merged
merged 5 commits into from
Mar 1, 2022

Conversation

harisha-swaminathan
Copy link
Contributor

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.

@welcome
Copy link

welcome bot commented Feb 1, 2022

💖 Thanks for opening this pull request! 💖

Things that will help get your PR across the finish line:

  • Run npm run lint -- --errors locally to catch formatting errors earlier.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

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.

Copy link
Member

@misteroneill misteroneill left a 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...

src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
test/unit/player.test.js Outdated Show resolved Hide resolved
src/css/components/_poster.scss Show resolved Hide resolved
@mister-ben
Copy link
Contributor

Either as part of this PR or as a followup, we should consider implementing userAction.click and doubleClick on the poster instead of the tech in audio poster mode - #7577

@misteroneill
Copy link
Member

@mister-ben Yeah, we should address that, but let's do it in a separate PR.

@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #7629 (38c8a6a) into main (eeda26f) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
src/js/player.js 88.03% <100.00%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eeda26f...38c8a6a. Read the comment docs.

@misteroneill misteroneill added the needs: LGTM Needs one or more additional approvals label Feb 8, 2022
@mister-ben
Copy link
Contributor

We should have some documentation in docs/guides/options.md until docs are moved elsewhere, otherwise looks good.

Copy link
Member

@gkatsev gkatsev left a 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();
Copy link
Member

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
Comment on lines 4304 to 4308
value = value && Boolean(value);

if (value === undefined || value === this.options_.audioPosterMode) {
return this.options_.audioPosterMode;
}
Copy link
Member

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

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

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
Comment on lines 4308 to 4310
value = value && Boolean(value);

if (value === undefined || typeof value !== 'boolean' || value === this.audioPosterMode_) {
Copy link
Member

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?

@misteroneill misteroneill added confirmed and removed needs: LGTM Needs one or more additional approvals labels Feb 14, 2022
@misteroneill misteroneill added the minor This PR can be added to a minor release. It should not be added to a patch release. label Feb 22, 2022
@misteroneill misteroneill merged commit 64e55f5 into videojs:main Mar 1, 2022
@welcome
Copy link

welcome bot commented Mar 1, 2022

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
confirmed minor This PR can be added to a minor release. It should not be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants