Allow changing volume by scrolling over any part of video player (#1254)

* Added toggle component to settings

* Setting to toggle this feature is now functional. Video volume can now be changed by scrolling anywhere on the video, or just on the slider, depending on this setting

* Added translation lines for en_US and en_GB

* Changed setting line from 'Scroll Volume Over Video' to 'Scroll Volume Over Video Player'

* Changed 'mousewheel' to 'wheel' event, as 'mousewheel' is deprecated

* Ran lint check in settings.js

Co-authored-by: Alex Stewart <albinexotech@gmail.com>
This commit is contained in:
Alex Stewart 2021-05-26 15:55:11 +00:00 committed by GitHub
parent 3bce276564
commit f9f5223f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 2 deletions

View File

@ -155,6 +155,10 @@ export default Vue.extend({
return this.$store.getters.getAutoplayVideos return this.$store.getters.getAutoplayVideos
}, },
videoVolumeMouseScroll: function () {
return this.$store.getters.getVideoVolumeMouseScroll
},
useSponsorBlock: function () { useSponsorBlock: function () {
return this.$store.getters.getUseSponsorBlock return this.$store.getters.getUseSponsorBlock
}, },
@ -251,7 +255,11 @@ export default Vue.extend({
this.player.on('mouseleave', this.removeMouseTimeout) this.player.on('mouseleave', this.removeMouseTimeout)
this.player.on('volumechange', this.updateVolume) this.player.on('volumechange', this.updateVolume)
this.player.controlBar.getChild('volumePanel').on('mousewheel', this.mouseScrollVolume) if (this.videoVolumeMouseScroll) {
this.player.on('wheel', this.mouseScrollVolume)
} else {
this.player.controlBar.getChild('volumePanel').on('wheel', this.mouseScrollVolume)
}
this.player.on('fullscreenchange', this.fullscreenOverlay) this.player.on('fullscreenchange', this.fullscreenOverlay)
this.player.on('fullscreenchange', this.toggleFullscreenClass) this.player.on('fullscreenchange', this.toggleFullscreenClass)

View File

@ -90,6 +90,10 @@ export default Vue.extend({
return this.$store.getters.getHideRecommendedVideos return this.$store.getters.getHideRecommendedVideos
}, },
videoVolumeMouseScroll: function () {
return this.$store.getters.getVideoVolumeMouseScroll
},
formatNames: function () { formatNames: function () {
return [ return [
this.$t('Settings.Player Settings.Default Video Format.Dash Formats'), this.$t('Settings.Player Settings.Default Video Format.Dash Formats'),
@ -127,7 +131,8 @@ export default Vue.extend({
'updateDefaultVolume', 'updateDefaultVolume',
'updateDefaultPlayback', 'updateDefaultPlayback',
'updateDefaultVideoFormat', 'updateDefaultVideoFormat',
'updateDefaultQuality' 'updateDefaultQuality',
'updateVideoVolumeMouseScroll'
]) ])
} }
}) })

View File

@ -37,6 +37,12 @@
:default-value="defaultTheatreMode" :default-value="defaultTheatreMode"
@change="updateDefaultTheatreMode" @change="updateDefaultTheatreMode"
/> />
<ft-toggle-switch
:label="$t('Settings.Player Settings.Scroll Volume Over Video Player')"
:compact="true"
:default-value="videoVolumeMouseScroll"
@change="updateVideoVolumeMouseScroll"
/>
</div> </div>
<div class="switchColumn"> <div class="switchColumn">
<ft-toggle-switch <ft-toggle-switch

View File

@ -77,6 +77,7 @@ const state = {
hidePlaylists: false, hidePlaylists: false,
hideLiveChat: false, hideLiveChat: false,
hideActiveSubscriptions: false, hideActiveSubscriptions: false,
videoVolumeMouseScroll: false,
useSponsorBlock: false, useSponsorBlock: false,
sponsorBlockUrl: 'https://sponsor.ajay.app', sponsorBlockUrl: 'https://sponsor.ajay.app',
sponsorBlockShowSkippedToast: true sponsorBlockShowSkippedToast: true
@ -267,6 +268,10 @@ const getters = {
return state.hideActiveSubscriptions return state.hideActiveSubscriptions
}, },
getVideoVolumeMouseScroll: () => {
return state.videoVolumeMouseScroll
},
getUseSponsorBlock: () => { getUseSponsorBlock: () => {
return state.useSponsorBlock return state.useSponsorBlock
}, },
@ -432,6 +437,9 @@ const actions = {
case 'hideActiveSubscriptions': case 'hideActiveSubscriptions':
commit('setHideActiveSubscriptions', result.value) commit('setHideActiveSubscriptions', result.value)
break break
case 'videoVolumeMouseScroll':
commit('setVideoVolumeMouseScroll', result.value)
break
case 'useSponsorBlock': case 'useSponsorBlock':
commit('setUseSponsorBlock', result.value) commit('setUseSponsorBlock', result.value)
break break
@ -811,6 +819,14 @@ const actions = {
}) })
}, },
updateVideoVolumeMouseScroll ({ commit }, videoVolumeMouseScroll) {
settingsDb.update({ _id: 'videoVolumeMouseScroll' }, { _id: 'videoVolumeMouseScroll', value: videoVolumeMouseScroll }, { upsert: true }, (err, numReplaced) => {
if (!err) {
commit('setVideoVolumeMouseScroll', videoVolumeMouseScroll)
}
})
},
updateUseSponsorBlock ({ commit }, useSponsorBlock) { updateUseSponsorBlock ({ commit }, useSponsorBlock) {
settingsDb.update({ _id: 'useSponsorBlock' }, { _id: 'useSponsorBlock', value: useSponsorBlock }, { upsert: true }, (err, numReplaced) => { settingsDb.update({ _id: 'useSponsorBlock' }, { _id: 'useSponsorBlock', value: useSponsorBlock }, { upsert: true }, (err, numReplaced) => {
if (!err) { if (!err) {
@ -992,6 +1008,9 @@ const mutations = {
setHideActiveSubscriptions (state, hideActiveSubscriptions) { setHideActiveSubscriptions (state, hideActiveSubscriptions) {
state.hideActiveSubscriptions = hideActiveSubscriptions state.hideActiveSubscriptions = hideActiveSubscriptions
}, },
setVideoVolumeMouseScroll (state, videoVolumeMouseScroll) {
state.videoVolumeMouseScroll = videoVolumeMouseScroll
},
setUseSponsorBlock (state, useSponsorBlock) { setUseSponsorBlock (state, useSponsorBlock) {
state.useSponsorBlock = useSponsorBlock state.useSponsorBlock = useSponsorBlock
}, },

View File

@ -173,6 +173,7 @@ Settings:
Proxy Videos Through Invidious: Proxy Videos Through Invidious Proxy Videos Through Invidious: Proxy Videos Through Invidious
Autoplay Playlists: Autoplay Playlists Autoplay Playlists: Autoplay Playlists
Enable Theatre Mode by Default: Enable Theatre Mode by Default Enable Theatre Mode by Default: Enable Theatre Mode by Default
Scroll Volume Over Video Player: Scroll Volume Over Video Player
Next Video Interval: Next Video Interval Next Video Interval: Next Video Interval
Default Volume: Default Volume Default Volume: Default Volume
Default Playback Rate: Default Playback Rate Default Playback Rate: Default Playback Rate

View File

@ -170,6 +170,7 @@ Settings:
Proxy Videos Through Invidious: 'Proxy Videos Through Invidious' Proxy Videos Through Invidious: 'Proxy Videos Through Invidious'
Autoplay Playlists: 'Autoplay Playlists' Autoplay Playlists: 'Autoplay Playlists'
Enable Theatre Mode by Default: 'Enable Theatre Mode by Default' Enable Theatre Mode by Default: 'Enable Theatre Mode by Default'
Scroll Volume Over Video Player: 'Scroll Volume Over Video Player'
Default Volume: 'Default Volume' Default Volume: 'Default Volume'
Default Playback Rate: 'Default Playback Rate' Default Playback Rate: 'Default Playback Rate'
Default Video Format: Default Video Format: