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

refactor: Unify audioOnly mode and audioPoster mode #7678

Merged
merged 9 commits into from
Mar 17, 2022

Conversation

harisha-swaminathan
Copy link
Contributor

@harisha-swaminathan harisha-swaminathan commented Mar 14, 2022

Modify the audioPosterMode method to return a promise and unify audioOnlyMode and audioPosterMode by turning off one mode when the other mode is turned on.

This change also disables/hides PIP for an audio source and when either of the two audio modes are true

@codecov
Copy link

codecov bot commented Mar 14, 2022

Codecov Report

Merging #7678 (1cecdfe) into main (b275a15) will increase coverage by 0.08%.
The diff coverage is 95.23%.

@@            Coverage Diff             @@
##             main    #7678      +/-   ##
==========================================
+ Coverage   80.74%   80.83%   +0.08%     
==========================================
  Files         116      116              
  Lines        7418     7447      +29     
  Branches     1794     1803       +9     
==========================================
+ Hits         5990     6020      +30     
+ Misses       1428     1427       -1     
Impacted Files Coverage Δ
src/js/control-bar/picture-in-picture-toggle.js 79.31% <85.71%> (+2.03%) ⬆️
src/js/player.js 88.37% <97.14%> (+0.23%) ⬆️
...rc/js/control-bar/progress-control/time-tooltip.js 84.61% <0.00%> (+2.56%) ⬆️

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 b275a15...1cecdfe. Read the comment docs.

@@ -4366,6 +4368,8 @@ class Player extends Component {
return this.audioOnlyMode_;
}

this.audioOnlyMode_ = value;

Copy link
Contributor Author

@harisha-swaminathan harisha-swaminathan Mar 14, 2022

Choose a reason for hiding this comment

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

Moved this here because this.audioOnlyMode_ was only getting updated after the promise was resolved and so outdated values were retuned when audioOnlyMode() was called in the audioPosterMode method

@harisha-swaminathan harisha-swaminathan marked this pull request as draft March 14, 2022 21:43
@harisha-swaminathan harisha-swaminathan marked this pull request as ready for review March 14, 2022 22:39
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.

One small thing and a suggestion for a comment. Looks great!

src/js/control-bar/picture-in-picture-toggle.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
Co-authored-by: Alex Barstow <alexander.barstow@gmail.com>
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.

💯

@misteroneill misteroneill changed the title feat: Unify audioOnly mode and audioPoster mode refactor: Unify audioOnly mode and audioPoster mode Mar 15, 2022
@@ -29,6 +29,20 @@ class PictureInPictureToggle extends Button {
this.on(player, ['enterpictureinpicture', 'leavepictureinpicture'], (e) => this.handlePictureInPictureChange(e));
this.on(player, ['disablepictureinpicturechanged', 'loadedmetadata'], (e) => this.handlePictureInPictureEnabledChange(e));

this.on(player, ['loadedmetadata', 'audioonlymodechange', 'audiopostermodechange'], () => {
const isSourceAudio = player.currentType().substring(0, 5) === 'audio';
Copy link
Contributor

Choose a reason for hiding this comment

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

This wouldn't work for audio-only HLS

Copy link
Member

Choose a reason for hiding this comment

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

It's not meant to, but perhaps that's worth adding a comment on.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure whether anyone actually uses it, but audio/mpegurl is a valid type for HLS. I believe it's valid for HLS even if it contains video.

Copy link
Member

Choose a reason for hiding this comment

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

the-more-you-know.gif

Yeah, I should be more clear here: the intent is merely to detect cases where we know the media is audio. For HLS or DASH audio-only streams, they may have a blank video track or no video track. Either way, VHS currently does not have a way to detect whether a stream is audio only.

So, we decided that the best course of action for the time being is to do the simple detection we can do.

Copy link
Contributor

Choose a reason for hiding this comment

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

In theory videoHeight() would be enough to know there's no video - but I can see getting into a situation where there seems to be no video initially when there eventually will be. Fair enough if it doesn't cover all cases, but comment/doc would be good so that's clearer down the line.

Copy link
Member

Choose a reason for hiding this comment

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

@misteroneill misteroneill merged commit eeff79c into videojs:main Mar 17, 2022
edirub pushed a commit to edirub/video.js that referenced this pull request Jun 8, 2023
Co-authored-by: Alex Barstow <alexander.barstow@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants