Skip to content

Option to skip through the video by scrolling #2418

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
merged 4 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/renderer/components/ft-video-player/ft-video-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ export default Vue.extend({
return this.$store.getters.getVideoPlaybackRateMouseScroll
},

videoSkipMouseScroll: function () {
return this.$store.getters.getVideoSkipMouseScroll
},

useSponsorBlock: function () {
return this.$store.getters.getUseSponsorBlock
},
Expand Down Expand Up @@ -478,6 +482,9 @@ export default Vue.extend({
this.player.el_.firstChild.style.pointerEvents = 'none'
this.player.on('click', this.handlePlayerClick)
}
if (this.videoSkipMouseScroll) {
this.player.on('wheel', this.mouseScrollSkip)
}

this.player.on('fullscreenchange', this.fullscreenOverlay)
this.player.on('fullscreenchange', this.toggleFullscreenClass)
Expand Down Expand Up @@ -721,6 +728,20 @@ export default Vue.extend({
}
},

mouseScrollSkip: function (event) {
// ensure that the mouse is over the player
if (event.target && (event.target.matches('.vjs-tech') || event.target.matches('.ftVideoPlayer'))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add some code comment to explain the selectors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest I have no idea why, but targeting just 'vjs-tech' doesn't seem to work all the time. 99% of the time it works just fine but in some rare cases '.ftVideoPlayer' gets targeted on hover and I don't know why. I added it as a selector just to account for that rare case. If I can figure out what's causing it maybe I can remove it.

event.preventDefault()

if (event.wheelDelta > 0) {
this.changeDurationBySeconds(this.defaultSkipInterval * this.player.playbackRate())
}
if (event.wheelDelta < 0) {
this.changeDurationBySeconds(-this.defaultSkipInterval * this.player.playbackRate())
}
}
},

handlePlayerClick: function (event) {
if (event.target.matches('.ftVideoPlayer')) {
if (event.ctrlKey || event.metaKey) {
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/components/player-settings/player-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export default Vue.extend({
return this.$store.getters.getVideoPlaybackRateMouseScroll
},

videoSkipMouseScroll: function () {
return this.$store.getters.getVideoSkipMouseScroll
},

displayVideoPlayButton: function () {
return this.$store.getters.getDisplayVideoPlayButton
},
Expand Down Expand Up @@ -274,6 +278,7 @@ export default Vue.extend({
'updateDefaultQuality',
'updateVideoVolumeMouseScroll',
'updateVideoPlaybackRateMouseScroll',
'updateVideoSkipMouseScroll',
'updateDisplayVideoPlayButton',
'updateEnterFullscreenOnDisplayRotate',
'updateMaxVideoPlaybackRate',
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/components/player-settings/player-settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<ft-toggle-switch
:label="$t('Settings.Player Settings.Scroll Volume Over Video Player')"
:compact="true"
:disabled="videoSkipMouseScroll"
:default-value="videoVolumeMouseScroll"
@change="updateVideoVolumeMouseScroll"
/>
Expand All @@ -45,6 +46,14 @@
:tooltip="$t('Tooltips.Player Settings.Scroll Playback Rate Over Video Player')"
@change="updateVideoPlaybackRateMouseScroll"
/>
<ft-toggle-switch
:label="$t('Settings.Player Settings.Skip by Scrolling Over Video Player')"
:compact="true"
:disabled="videoVolumeMouseScroll"
:default-value="videoSkipMouseScroll"
:tooltip="$t('Tooltips.Player Settings.Skip by Scrolling Over Video Player')"
@change="updateVideoSkipMouseScroll"
/>
</div>
<div class="switchColumn">
<ft-toggle-switch
Expand Down
1 change: 1 addition & 0 deletions src/renderer/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ const state = {
useSponsorBlock: false,
videoVolumeMouseScroll: false,
videoPlaybackRateMouseScroll: false,
videoSkipMouseScroll: false,
videoPlaybackRateInterval: 0.25,
downloadFolderPath: '',
downloadBehavior: 'download',
Expand Down
2 changes: 2 additions & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ Settings:
Enable Theatre Mode by Default: Enable Theatre Mode by Default
Scroll Volume Over Video Player: Scroll Volume Over Video Player
Scroll Playback Rate Over Video Player: Scroll Playback Rate Over Video Player
Skip by Scrolling Over Video Player: Skip by Scrolling Over Video Player
Display Play Button In Video Player: Display Play Button In Video Player
Enter Fullscreen on Display Rotate: Enter Fullscreen on Display Rotate
Next Video Interval: Next Video Interval
Expand Down Expand Up @@ -763,6 +764,7 @@ Tooltips:
hold the Control key (Command Key on Mac) and scroll the mouse wheel forwards or backwards to control
the playback rate. Press and hold the Control key (Command Key on Mac) and left click the mouse
to quickly return to the default playback rate (1x unless it has been changed in the settings).
Skip by Scrolling Over Video Player: Use the scroll wheel to skip through the video, MPV style.
External Player Settings:
External Player: Choosing an external player will display an icon, for opening the
video (playlist if supported) in the external player, on the thumbnail. Warning, Invidious settings do not affect external players.
Expand Down