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: Audio Only Mode #7647

Merged
merged 17 commits into from
Mar 10, 2022
Merged

feat: Audio Only Mode #7647

merged 17 commits into from
Mar 10, 2022

Conversation

alex-barstow
Copy link
Contributor

@alex-barstow alex-barstow commented Feb 16, 2022

Description

This adds support for audioOnlyMode, which will hide all player children except the control bar, and within the control bar any controls that are only needed for video.

This can be enabled vis either the new player.audioOnlyMode() getter/setter or a audioOnlyMode option, which defaults to false

Specific Changes proposed

When audioOnlyMode is enabled:

  • Hide the tech and other player children, except the control bar
  • Lock the control bar in a visible state so it does not hide when the user is inactive
  • Hide the CaptionsButton, DescriptionButton, SubsCapsButton, FullscreenToggle, PictureInPictureToggle (this is done with CSS rather than JS to avoid unneeded complexity since some of these controls show/hide themselves dynamically depending on available support and/or the presence of certain text tracks.
  • Leave certain controls potentially useful for audio visible (ex. PlaybackRateMenuButton, ChaptersButton)
  • Set the player height equal to the control bar height
  • Trigger a 'audioonlymodechange' event

@codecov
Copy link

codecov bot commented Feb 16, 2022

Codecov Report

Merging #7647 (b9f39f7) into main (a80307f) will increase coverage by 0.10%.
The diff coverage is 91.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7647      +/-   ##
==========================================
+ Coverage   80.64%   80.74%   +0.10%     
==========================================
  Files         116      116              
  Lines        7373     7418      +45     
  Branches     1782     1794      +12     
==========================================
+ Hits         5946     5990      +44     
- Misses       1427     1428       +1     
Impacted Files Coverage Δ
src/js/player.js 88.14% <91.11%> (+0.08%) ⬆️
src/js/component.js 93.91% <0.00%> (+0.45%) ⬆️
src/js/tracks/text-track.js 92.30% <0.00%> (+0.64%) ⬆️

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 a80307f...b9f39f7. Read the comment docs.

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.

Miscellaneous thoughts!

src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
alex-barstow and others added 3 commits February 24, 2022 11:23
Co-authored-by: Pat O'Neill <pgoneill@gmail.com>
Co-authored-by: Pat O'Neill <pgoneill@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.

Nevermind, change of plans!

@misteroneill misteroneill dismissed their stale review March 1, 2022 21:01

Nevermind, change of plans!

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.

A couple of tiny comments

src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated
Comment on lines 4347 to 4350
// Fullscreen is not supported in audioOnlyMode, so exit if we need to
if (this.isFullscreen()) {
this.exitFullscreen();
}
Copy link
Member

Choose a reason for hiding this comment

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

should we also exit PiP?

Copy link
Member

Choose a reason for hiding this comment

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

should we exit fs/pip before getting the control bar height, in case it's different in fullscreen? At least exitFullscreen should have a promise for knowing when exiting has finished.

@gkatsev
Copy link
Member

gkatsev commented Mar 1, 2022

also, if you set font-size: 3em on the player div and the control bar is huge, it doesn't like this mode much. For example, hovering on the volume panel to open it up makes the whole player grow.
Aside from that, works great and the inline: false volume panel works fine too.

@@ -2161,6 +2162,7 @@ QUnit.test('When VIDEOJS_NO_DYNAMIC_STYLE is set, apply sizing directly to the t
assert.equal(player.tech_.el().width, 600, 'the width is equal to 600');
assert.equal(player.tech_.el().height, 300, 'the height is equal 300');
player.dispose();
window.VIDEOJS_NO_DYNAMIC_STYLE = originalVjsNoDynamicStyling;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This state was leaking, causing the below 'audioOnlyMode(true/false) changes player height' test to fail.

@thijstriemstra
Copy link
Contributor

thijstriemstra commented Jul 30, 2022

Really cool feature @alex-barstow.

I was surprised to see it in a >= 7.18.1 release, I would've preferred to see it in a major release..

Fortunately it didn't break anything in my 'audio only plugin' for video.js which I've been maintaining since video.js 4.x: https://github.com/collab-project/videojs-wavesurfer

Now that video.js finally supports an audio-only mode, I guess I'll have to revisit my plugin at some point and remove all the nasty hacks in order to support wavesurfer.js/audio-only.

ps. because fairly major things are still added to video.js 7.x, can we expect the 7.x versioning to stay for(ever/awhile) or will there be a video.js 8 at some point @gkatsev?

@gkatsev
Copy link
Member

gkatsev commented Aug 2, 2022

Video.js 8 is coming. Since this is a new feature, with theoretically no breakages, it should come in a minor release (it was released in 7.19.0).

Would love to see an updated version of your plugin that interfaces with the audio-only mode.

edirub pushed a commit to edirub/video.js that referenced this pull request Jun 8, 2023
* audioOnlyMode wip

* fix incorrect logs

* add tests

* minor code changes and add another test

* update docs

* fix formatting

* fix typo

* Consolidate conditions

Co-authored-by: Pat O'Neill <pgoneill@gmail.com>

* Compare objects instead of name string

Co-authored-by: Pat O'Neill <pgoneill@gmail.com>

* code review changes

* remove unnecessary equivalence check

Co-authored-by: Gary Katsevman <git@gkatsev.com>

* replace height() with currentHeight()

Co-authored-by: Gary Katsevman <git@gkatsev.com>

* rewrite for async pip and fs handling

* asyncify tests

* update doc

* add test

Co-authored-by: Pat O'Neill <pgoneill@gmail.com>
Co-authored-by: Gary Katsevman <git@gkatsev.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