* Implement playlist countdown per second (#1234)

Closes: #1214
This commit is contained in:
PikachuEXE 2021-04-30 00:58:00 +08:00 committed by GitHub
parent 2186448dee
commit 76260d9c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 9 deletions

View File

@ -876,16 +876,35 @@ export default Vue.extend({
} }
}, nextVideoInterval * 1000) }, nextVideoInterval * 1000)
let countDownTimeLeftInSecond = nextVideoInterval
const showCountDownMessage = () => {
// Will not display "Playing next video in no time" as it's too late to cancel
// Also there is a separate message when playing next video
if (countDownTimeLeftInSecond <= 0) {
clearInterval(countDownIntervalId)
return
}
this.showToast({ this.showToast({
message: this.$tc('Playing Next Video Interval', nextVideoInterval, { nextVideoInterval: nextVideoInterval }), message: this.$tc('Playing Next Video Interval', countDownTimeLeftInSecond, { nextVideoInterval: countDownTimeLeftInSecond }),
time: (nextVideoInterval * 1000) + 500, // To avoid message flashing
// `time` is manually tested to be 700
time: 700,
action: () => { action: () => {
clearTimeout(this.playNextTimeout) clearTimeout(this.playNextTimeout)
clearInterval(countDownIntervalId)
this.showToast({ this.showToast({
message: this.$t('Canceled next video autoplay') message: this.$t('Canceled next video autoplay')
}) })
} }
}) })
// At least this var should be updated AFTER showing the message
countDownTimeLeftInSecond = countDownTimeLeftInSecond - 1
}
// Execute once before scheduling it
showCountDownMessage()
const countDownIntervalId = setInterval(showCountDownMessage, 1000)
} else if (this.playNextVideo) { } else if (this.playNextVideo) {
this.playNextTimeout = setTimeout(() => { this.playNextTimeout = setTimeout(() => {
const player = this.$refs.videoPlayer.player const player = this.$refs.videoPlayer.player