-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Autoplay time limit #5871
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
Changes from all commits
27f59e0
fbe14dc
672b92a
c82634d
ffa79f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,8 @@ export default defineComponent({ | |
beforeRouteLeave: async function (to, from, next) { | ||
this.handleRouteChange() | ||
window.removeEventListener('beforeunload', this.handleWatchProgress) | ||
document.removeEventListener('keydown', this.resetAutoplayInterruptionTimeout) | ||
document.removeEventListener('click', this.resetAutoplayInterruptionTimeout) | ||
|
||
if (this.$refs.player) { | ||
await this.$refs.player.destroyPlayer() | ||
|
@@ -119,6 +121,8 @@ export default defineComponent({ | |
playNextTimeout: null, | ||
playNextCountDownIntervalId: null, | ||
infoAreaSticky: true, | ||
blockVideoAutoplay: false, | ||
autoplayInterruptionTimeout: null, | ||
|
||
onMountedRun: false, | ||
|
||
|
@@ -160,6 +164,9 @@ export default defineComponent({ | |
proxyVideos: function () { | ||
return this.$store.getters.getProxyVideos | ||
}, | ||
defaultAutoplayInterruptionIntervalHours: function () { | ||
return this.$store.getters.getDefaultAutoplayInterruptionIntervalHours | ||
}, | ||
defaultInterval: function () { | ||
return this.$store.getters.getDefaultInterval | ||
}, | ||
|
@@ -321,7 +328,13 @@ export default defineComponent({ | |
this.getVideoInformationLocal() | ||
} | ||
|
||
document.removeEventListener('keydown', this.resetAutoplayInterruptionTimeout) | ||
document.removeEventListener('click', this.resetAutoplayInterruptionTimeout) | ||
document.addEventListener('keydown', this.resetAutoplayInterruptionTimeout) | ||
document.addEventListener('click', this.resetAutoplayInterruptionTimeout) | ||
|
||
window.addEventListener('beforeunload', this.handleWatchProgress) | ||
this.resetAutoplayInterruptionTimeout() | ||
}, | ||
|
||
changeTimestamp: function (timestamp) { | ||
|
@@ -1233,6 +1246,18 @@ export default defineComponent({ | |
return | ||
} | ||
|
||
if (this.blockVideoAutoplay) { | ||
showToast(this.$t('Autoplay Interruption Timer', | ||
this.defaultAutoplayInterruptionIntervalHours, | ||
{ | ||
autoplayInterruptionIntervalHours: this.defaultAutoplayInterruptionIntervalHours | ||
}), | ||
3_600_000 | ||
) | ||
Comment on lines
+1255
to
+1256
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am surprised that linter is ok with this o_0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It not only tolerates it: it enforces it to be like that. ¯\(ツ)/¯ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason that is happening is because Moving It would also improve the general readability of that code snippet if the placeholder name in the translation string weren't so long e.g. However as both things are stylistic issues and don't influence the functionality of the code, we can leave the cleanup for some future pull request. |
||
this.resetAutoplayInterruptionTimeout() | ||
return | ||
} | ||
|
||
if (this.watchingPlaylist && this.getPlaylistPauseOnCurrent()) { | ||
this.disablePlaylistPauseOnCurrent() | ||
return | ||
|
@@ -1639,6 +1664,12 @@ export default defineComponent({ | |
this.updatePlaylistLastPlayedAt({ _id: playlist._id }) | ||
}, | ||
|
||
resetAutoplayInterruptionTimeout() { | ||
clearTimeout(this.autoplayInterruptionTimeout) | ||
this.autoplayInterruptionTimeout = setTimeout(() => { this.blockVideoAutoplay = true }, this.defaultAutoplayInterruptionIntervalHours * 3_600_000) | ||
this.blockVideoAutoplay = false | ||
}, | ||
|
||
...mapActions([ | ||
'updateHistory', | ||
'updateWatchProgress', | ||
|
Uh oh!
There was an error while loading. Please reload this page.