From bac649e52eca7189e197eb02dc3d781ab1570698 Mon Sep 17 00:00:00 2001 From: Boris Yakubchik Date: Sun, 18 Jul 2021 01:07:50 -0400 Subject: [PATCH] space bar plays random video --- i18n/en.json | 8 +++++--- src/app/common/settings-buttons.ts | 12 ++++++++++-- src/app/components/home.component.ts | 5 +++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 79348c28..a914f485 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -148,9 +148,6 @@ "sizeFilterDescription": "Size", "sizeFilterHint": "Size filter", "sizeFilterMoreInfo": "Show the size filter", - "timesPlayedDescription": "Times Played", - "timesPlayedHint": "Times Played filter", - "timesPlayedMoreInfo": "Show the times played filter", "sortOptionAlphabeticalDescription": "Alphabetical", "sortOptionAlphabeticalDescription2": "Alphabetical 2", "sortOptionAlphabeticalMoreInfo": "Show the alphabetical order option in the sorting dropdown", @@ -181,6 +178,8 @@ "sortOrderDescription": "Sort order", "sortOrderHint": "Sort order", "sortOrderMoreInfo": "Show the sort order filter", + "spacePlaysRandomDescription": "Pressing spacebar plays random video from random starting time", + "spacePlaysRandomMoreInfo": "Random starting time only works when preferred video player is set", "starFilterDescription": "Star", "starFilterHint": "Star filter", "starFilterMoreInfo": "Show the star filter", @@ -202,6 +201,9 @@ "thumbAutoAdvanceDescription": "Cycle on hover", "thumbAutoAdvanceHint": "Enable thumbnail auto advance", "thumbAutoAdvanceMoreInfo": "Hovering over thumbnails cycles through screenshots", + "timesPlayedDescription": "Times Played", + "timesPlayedHint": "Times Played filter", + "timesPlayedMoreInfo": "Show the times played filter", "videoNotesDescription": "Notes search", "videoNotesHint": "Notes search", "videoNotesMoreInfo": "Search through the notes you have added to your videos. Enable notes in the Tags settings", diff --git a/src/app/common/settings-buttons.ts b/src/app/common/settings-buttons.ts index 7785ad18..f47ddce0 100644 --- a/src/app/common/settings-buttons.ts +++ b/src/app/common/settings-buttons.ts @@ -52,8 +52,8 @@ export type SettingsButtonKey = 'autoFileTags' | 'showRecent' | 'showRecentlyPlayed' | 'showRelatedVideosTray' - | 'showTagTray' | 'showTags' + | 'showTagTray' | 'showThumbnails' | 'showVideoNotes' | 'shuffleGalleryNow' @@ -72,6 +72,7 @@ export type SettingsButtonKey = 'autoFileTags' | 'sortOptionTimesPlayed' | 'sortOptionYear' | 'sortOrder' + | 'spacePlaysRandom' | 'starFilter' | 'startWizard' | 'tagExclusion' @@ -193,6 +194,7 @@ export const SettingsButtonsGroups: SettingsButtonKey[][] = [ 'showDeleteOption', 'dangerousDelete', 'playPlaylist', + 'spacePlaysRandom', 'openAtTimestamp', ] ]; @@ -728,7 +730,13 @@ export const SettingsButtons: SettingsButtonsType = { title: '', toggled: false }, - + 'spacePlaysRandom': { + description: 'BUTTONS.spacePlaysRandomDescription', + hidden: false, + moreInfo: 'BUTTONS.spacePlaysRandomMoreInfo', + title: '', + toggled: false + }, 'sortOptionFps': { description: 'BUTTONS.sortOptionFpsDescription', hidden: false, diff --git a/src/app/components/home.component.ts b/src/app/components/home.component.ts index d3957246..c1f53ee0 100644 --- a/src/app/components/home.component.ts +++ b/src/app/components/home.component.ts @@ -343,6 +343,11 @@ export class HomeComponent implements OnInit, AfterViewInit { this.sheetOverlayShowing = false; } else if (event.key === 'Escape' && this.settingsButtons['showTags'].toggled) { this.toggleButton('showTags'); + } else if (event.key === ' ' && this.settingsButtons['spacePlaysRandom'].toggled) { + const randomIndex: number = Math.floor(Math.random() * this.pipeSideEffectService.galleryShowing.length); + const video: ImageElement = this.pipeSideEffectService.galleryShowing[randomIndex]; + const randomPlayStart: number = Math.floor(Math.random() * video.screens); + this.openVideo(video, randomPlayStart); } }