-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add autoplay toggle to the video player #5866
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
Merged
FreeTubeBot
merged 10 commits into
FreeTubeApp:development
from
kommunarr:feat/autoplay-in-media-player
Jan 14, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6f7795d
Add autoplay toggle to the video player
kommunarr d246be7
Fix (pre-existing) bug where mobile Shaka overflow menu overflows int…
kommunarr 4317f3e
Update confusing autoplay labels to use consistent language
kommunarr 5c5349e
Update src/renderer/components/ft-shaka-video-player/player-component…
kommunarr dba83e3
Have autoplay toggle value update when setting updates elsewhere, e.g…
kommunarr 01c693d
Merge branch 'feat/autoplay-in-media-player' of github.com:kommunarr/…
kommunarr 2b17208
Apply suggestions from code review
kommunarr 3a55565
Remove now-redundant playlist pause feature
kommunarr 1daad86
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr 1f2369a
Update overflow width threshold
kommunarr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/renderer/components/ft-shaka-video-player/player-components/AutoplayToggle.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import shaka from 'shaka-player' | ||
|
|
||
| import i18n from '../../../i18n/index' | ||
|
|
||
| export class AutoplayToggle extends shaka.ui.Element { | ||
| /** | ||
| * @param {boolean} autoplayEnabled | ||
| * @param {EventTarget} events | ||
kommunarr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @param {HTMLElement} parent | ||
| * @param {shaka.ui.Controls} controls | ||
| */ | ||
| constructor(autoplayEnabled, events, parent, controls) { | ||
| super(parent, controls) | ||
|
|
||
| /** @private */ | ||
| this.button_ = document.createElement('button') | ||
| this.button_.classList.add('autoplay-toggle') | ||
| this.button_.classList.add('shaka-tooltip') | ||
|
|
||
| /** @private */ | ||
| this.icon_ = document.createElement('i') | ||
| this.icon_.classList.add('material-icons-round') | ||
| this.icon_.textContent = 'pause_circle' | ||
|
|
||
| this.button_.appendChild(this.icon_) | ||
|
|
||
| const label = document.createElement('label') | ||
| label.classList.add('shaka-overflow-button-label') | ||
| label.classList.add('shaka-overflow-menu-only') | ||
|
|
||
| /** @private */ | ||
| this.nameSpan_ = document.createElement('span') | ||
| label.appendChild(this.nameSpan_) | ||
|
|
||
| /** @private */ | ||
| this.currentState_ = document.createElement('span') | ||
| this.currentState_.classList.add('shaka-current-selection-span') | ||
| label.appendChild(this.currentState_) | ||
|
|
||
| this.button_.appendChild(label) | ||
|
|
||
| this.parent.appendChild(this.button_) | ||
|
|
||
| /** @private */ | ||
| this.autoplayEnabled_ = autoplayEnabled | ||
|
|
||
| // listeners | ||
|
|
||
| this.eventManager.listen(this.button_, 'click', () => { | ||
| events.dispatchEvent(new CustomEvent('toggleAutoplay', { | ||
| detail: !this.autoplayEnabled_ | ||
| })) | ||
absidue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
|
|
||
| const handleAutoplayValueChange = (/** @type {CustomEvent} */ event) => { | ||
| this.autoplayEnabled_ = event.detail | ||
| this.updateLocalisedStrings_() | ||
| } | ||
|
|
||
| this.eventManager.listen(events, 'setAutoplay', handleAutoplayValueChange) | ||
|
|
||
| this.eventManager.listen(events, 'localeChanged', () => { | ||
| this.updateLocalisedStrings_() | ||
| }) | ||
|
|
||
| this.updateLocalisedStrings_() | ||
| } | ||
|
|
||
| /** @private */ | ||
| updateLocalisedStrings_() { | ||
| this.nameSpan_.textContent = i18n.t('Video.Autoplay') | ||
|
|
||
| this.icon_.textContent = this.autoplayEnabled_ ? 'play_circle' : 'pause_circle' | ||
|
|
||
| this.currentState_.textContent = this.localization.resolve(this.autoplayEnabled_ ? 'ON' : 'OFF') | ||
|
|
||
| this.button_.ariaLabel = this.autoplayEnabled_ ? i18n.t('Video.Player.Autoplay is on') : i18n.t('Video.Player.Autoplay is off') | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.