Apply playlist autoplay interval to regular autoplay

The interval to play the next video in a playlist was dynamic and
wasn't applied to the normal autoplay timer.
This commit merges the logic of these two scenarios so that they both
utilize the user-defined interval.
This commit is contained in:
Svallinn 2021-04-29 19:33:13 +01:00
parent 76260d9c4c
commit e696af3f7a
No known key found for this signature in database
GPG Key ID: 09FB527F34037CCA
3 changed files with 36 additions and 50 deletions

View File

@ -62,7 +62,7 @@
</div> </div>
<ft-flex-box> <ft-flex-box>
<ft-slider <ft-slider
:label="$t('Settings.Player Settings.Playlist Next Video Interval')" :label="$t('Settings.Player Settings.Next Video Interval')"
:default-value="defaultInterval" :default-value="defaultInterval"
:min-value="0" :min-value="0"
:max-value="60" :max-value="60"

View File

@ -867,12 +867,25 @@ export default Vue.extend({
}, },
handleVideoEnded: function () { handleVideoEnded: function () {
if (!this.watchingPlaylist && !this.playNextVideo) {
return
}
const nextVideoInterval = this.defaultInterval const nextVideoInterval = this.defaultInterval
if (this.watchingPlaylist) {
this.playNextTimeout = setTimeout(() => { this.playNextTimeout = setTimeout(() => {
const player = this.$refs.videoPlayer.player const player = this.$refs.videoPlayer.player
if (player !== null && player.paused()) { if (player !== null && player.paused()) {
if (this.watchingPlaylist) {
this.$refs.watchVideoPlaylist.playNextVideo() this.$refs.watchVideoPlaylist.playNextVideo()
} else {
const nextVideoId = this.recommendedVideos[0].videoId
this.$router.push({
path: `/watch/${nextVideoId}`
})
this.showToast({
message: this.$t('Playing Next Video')
})
}
} }
}, nextVideoInterval * 1000) }, nextVideoInterval * 1000)
@ -905,33 +918,6 @@ export default Vue.extend({
// Execute once before scheduling it // Execute once before scheduling it
showCountDownMessage() showCountDownMessage()
const countDownIntervalId = setInterval(showCountDownMessage, 1000) const countDownIntervalId = setInterval(showCountDownMessage, 1000)
} else if (this.playNextVideo) {
this.playNextTimeout = setTimeout(() => {
const player = this.$refs.videoPlayer.player
if (player !== null && player.paused()) {
const nextVideoId = this.recommendedVideos[0].videoId
this.$router.push(
{
path: `/watch/${nextVideoId}`
}
)
this.showToast({
message: this.$t('Playing Next Video')
})
}
}, 5000)
this.showToast({
message: this.$t('Playing next video in 5 seconds. Click to cancel'),
time: 5500,
action: () => {
clearTimeout(this.playNextTimeout)
this.showToast({
message: this.$t('Canceled next video autoplay')
})
}
})
}
}, },
handleRouteChange: function () { handleRouteChange: function () {

View File

@ -171,7 +171,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
Playlist Next Video Interval: Playlist 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
Default Video Format: Default Video Format: