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

Autoplay time limit #5871

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default defineComponent({
vrProjection: {
type: String,
default: null
}
},
},
emits: [
'error',
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 @@ -95,6 +95,10 @@ export default defineComponent({
return this.backendPreference !== 'invidious' && !this.backendFallback
},

defaultAutoplayInterruptionInterval: function () {
return parseInt(this.$store.getters.getDefaultAutoplayInterruptionInterval)
},

defaultSkipInterval: function () {
return parseInt(this.$store.getters.getDefaultSkipInterval)
},
Expand Down Expand Up @@ -286,6 +290,7 @@ export default defineComponent({
...mapActions([
'updateAutoplayVideos',
'updateAutoplayPlaylists',
'updateDefaultAutoplayInterruptionInterval',
'updatePlayNextVideo',
'updateEnableSubtitlesByDefault',
'updateProxyVideos',
Expand Down
27 changes: 18 additions & 9 deletions src/renderer/components/player-settings/player-settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@
</div>
</div>
<ft-flex-box>
<ft-slider
:label="$t('Settings.Player Settings.Fast-Forward / Rewind Interval')"
:default-value="defaultSkipInterval"
:min-value="1"
:max-value="70"
:step="1"
value-extension="s"
@change="updateDefaultSkipInterval"
/>
<ft-slider
:label="$t('Settings.Player Settings.Next Video Interval')"
:default-value="defaultInterval"
Expand All @@ -100,6 +91,24 @@
value-extension="s"
@change="updateDefaultInterval"
/>
<ft-slider
:label="$t('Settings.Player Settings.Autoplay Interruption Timer')"
:default-value="defaultAutoplayInterruptionInterval"
:min-value="1"
:max-value="12"
:step="1"
value-extension="h"
@change="updateDefaultAutoplayInterruptionInterval"
/>
<ft-slider
:label="$t('Settings.Player Settings.Fast-Forward / Rewind Interval')"
:default-value="defaultSkipInterval"
:min-value="1"
:max-value="70"
:step="1"
value-extension="s"
@change="updateDefaultSkipInterval"
/>
<ft-slider
:label="$t('Settings.Player Settings.Default Volume')"
:default-value="defaultVolume"
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 @@ -172,6 +172,7 @@ const state = {
baseTheme: 'system',
mainColor: 'Red',
secColor: 'Blue',
defaultAutoplayInterruptionInterval: 3,
kommunarr marked this conversation as resolved.
Show resolved Hide resolved
defaultCaptionSettings: '{}',
defaultInterval: 5,
defaultPlayback: 1,
Expand Down
22 changes: 22 additions & 0 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default defineComponent({
beforeRouteLeave: async function (to, from, next) {
this.handleRouteChange()
window.removeEventListener('beforeunload', this.handleWatchProgress)
document.removeEventListener('click', this.resetAutoplayInterruptionTimeout)

if (this.$refs.player) {
await this.$refs.player.destroyPlayer()
Expand Down Expand Up @@ -119,6 +120,8 @@ export default defineComponent({
playNextTimeout: null,
playNextCountDownIntervalId: null,
infoAreaSticky: true,
blockVideoAutoplay: false,
autoplayInterruptionTimeout: null,

onMountedRun: false,

Expand Down Expand Up @@ -160,6 +163,9 @@ export default defineComponent({
proxyVideos: function () {
return this.$store.getters.getProxyVideos
},
defaultAutoplayInterruptionInterval: function () {
return this.$store.getters.getDefaultAutoplayInterruptionInterval
},
defaultInterval: function () {
return this.$store.getters.getDefaultInterval
},
Expand Down Expand Up @@ -321,7 +327,11 @@ export default defineComponent({
this.getVideoInformationLocal()
}

document.removeEventListener('click', this.resetAutoplayInterruptionTimeout)
document.addEventListener('click', this.resetAutoplayInterruptionTimeout)
kommunarr marked this conversation as resolved.
Show resolved Hide resolved

window.addEventListener('beforeunload', this.handleWatchProgress)
this.resetAutoplayInterruptionTimeout()
},

changeTimestamp: function (timestamp) {
Expand Down Expand Up @@ -1233,6 +1243,12 @@ export default defineComponent({
return
}

if (this.blockVideoAutoplay) {
showToast(this.$t('Canceled next video autoplay due to inactivity'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should stay visible for longer (1 hour?)
New users (new to this setting) will take time to realize the playlist is stopped and switch back and wondering why it's stopped
Also the text should mention the setting name if possible, but at least should include the value (e.g. 3h)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How about this?

Screenshot_20241204_010228

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks better

this.resetAutoplayInterruptionTimeout()
return
}

if (this.watchingPlaylist && this.getPlaylistPauseOnCurrent()) {
this.disablePlaylistPauseOnCurrent()
return
Expand Down Expand Up @@ -1639,6 +1655,12 @@ export default defineComponent({
this.updatePlaylistLastPlayedAt({ _id: playlist._id })
},

resetAutoplayInterruptionTimeout() {
clearTimeout(this.autoplayInterruptionTimeout)
this.autoplayInterruptionTimeout = setTimeout(() => { this.blockVideoAutoplay = true }, this.defaultAutoplayInterruptionInterval * 3_600_000)
this.blockVideoAutoplay = false
},

...mapActions([
'updateHistory',
'updateWatchProgress',
Expand Down
4 changes: 3 additions & 1 deletion static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ Settings:
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
Next Video Interval: Autoplay Countdown Timer
Autoplay Interruption Timer: Autoplay Interruption Timer
Fast-Forward / Rewind Interval: Fast-Forward / Rewind Interval
Default Volume: Default Volume
Default Playback Rate: Default Playback Rate
Expand Down Expand Up @@ -1056,6 +1057,7 @@ Playlist will not pause when current video is finished: Playlist will not pause
Playlist will pause when current video is finished: Playlist will pause when current video is finished
Playing Next Video Interval: Playing next video in no time. Click to cancel. | Playing next video in {nextVideoInterval} second. Click to cancel. | Playing next video in {nextVideoInterval} seconds. Click to cancel.
Canceled next video autoplay: Canceled next video autoplay
Canceled next video autoplay due to inactivity: Canceled next video autoplay due to inactivity

Default Invidious instance has been set to {instance}: Default Invidious instance has been set to {instance}
Default Invidious instance has been cleared: Default Invidious instance has been cleared
Expand Down