Skip to content

Commit fbe14dc

Browse files
committed
Update implementation to block next video autoplay
i.e., instead of 'start video automatically' autoplay
1 parent 27f59e0 commit fbe14dc

File tree

5 files changed

+12
-24
lines changed

5 files changed

+12
-24
lines changed

src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,11 @@ export default defineComponent({
107107
type: String,
108108
default: null
109109
},
110-
blockVideoAutoplay: {
111-
type: Boolean,
112-
default: false
113-
}
114110
},
115111
emits: [
116112
'error',
117113
'loaded',
118114
'ended',
119-
'reset-autoplay-interruption-timeout',
120115
'timeupdate',
121116
'toggle-theatre-mode'
122117
],
@@ -160,15 +155,6 @@ export default defineComponent({
160155
*/
161156
let sortedCaptions
162157

163-
const blockAutoplay = props.blockVideoAutoplay
164-
if (blockAutoplay) {
165-
resetAutoplayInterruptionTimeout()
166-
}
167-
168-
function resetAutoplayInterruptionTimeout() {
169-
emit('reset-autoplay-interruption-timeout')
170-
}
171-
172158
// we don't need to sort if we only have one caption or don't have any
173159
if (props.captions.length > 1) {
174160
// theoretically we would resort when the language changes, but we can't remove captions that we already added to the player
@@ -1973,8 +1959,6 @@ export default defineComponent({
19731959
* @param {KeyboardEvent} event
19741960
*/
19751961
function keyboardShortcutHandler(event) {
1976-
resetAutoplayInterruptionTimeout()
1977-
19781962
if (!player || !hasLoaded.value) {
19791963
return
19801964
}
@@ -2381,9 +2365,6 @@ export default defineComponent({
23812365
document.removeEventListener('keydown', keyboardShortcutHandler)
23822366
document.addEventListener('keydown', keyboardShortcutHandler)
23832367

2384-
document.removeEventListener('click', resetAutoplayInterruptionTimeout)
2385-
document.addEventListener('click', resetAutoplayInterruptionTimeout)
2386-
23872368
player.addEventListener('loading', () => {
23882369
hasLoaded.value = false
23892370
})
@@ -2692,7 +2673,6 @@ export default defineComponent({
26922673
document.body.classList.remove('playerFullWindow')
26932674

26942675
document.removeEventListener('keydown', keyboardShortcutHandler)
2695-
document.removeEventListener('click', resetAutoplayInterruptionTimeout)
26962676

26972677
if (resizeObserver) {
26982678
resizeObserver.disconnect()
@@ -2788,7 +2768,6 @@ export default defineComponent({
27882768
stats,
27892769

27902770
autoplayVideos,
2791-
blockAutoplay,
27922771
sponsorBlockShowSkippedToast,
27932772

27942773
skippedSponsorBlockSegments,

src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
preload="auto"
1515
crossorigin="anonymous"
1616
playsinline
17-
:autoplay="autoplayVideos && !blockAutoplay ? true : null"
17+
:autoplay="autoplayVideos ? true : null"
1818
:poster="thumbnail"
1919
@play="handlePlay"
2020
@pause="handlePause"

src/renderer/views/Watch/Watch.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default defineComponent({
5757
beforeRouteLeave: async function (to, from, next) {
5858
this.handleRouteChange()
5959
window.removeEventListener('beforeunload', this.handleWatchProgress)
60+
document.removeEventListener('click', this.resetAutoplayInterruptionTimeout)
6061

6162
if (this.$refs.player) {
6263
await this.$refs.player.destroyPlayer()
@@ -324,6 +325,9 @@ export default defineComponent({
324325
this.getVideoInformationLocal()
325326
}
326327

328+
document.removeEventListener('click', this.resetAutoplayInterruptionTimeout)
329+
document.addEventListener('click', this.resetAutoplayInterruptionTimeout)
330+
327331
window.addEventListener('beforeunload', this.handleWatchProgress)
328332
this.resetAutoplayInterruptionTimeout()
329333
},
@@ -1192,6 +1196,12 @@ export default defineComponent({
11921196
return
11931197
}
11941198

1199+
if (this.blockVideoAutoplay) {
1200+
showToast(this.$t('Canceled next video autoplay due to inactivity'))
1201+
this.resetAutoplayInterruptionTimeout()
1202+
return
1203+
}
1204+
11951205
if (this.watchingPlaylist && this.getPlaylistPauseOnCurrent()) {
11961206
this.disablePlaylistPauseOnCurrent()
11971207
return

src/renderer/views/Watch/Watch.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@
3434
:theatre-possible="theatrePossible"
3535
:use-theatre-mode="useTheatreMode"
3636
:vr-projection="vrProjection"
37-
:block-video-autoplay="blockVideoAutoplay"
3837
class="videoPlayer"
3938
@error="handlePlayerError"
4039
@loaded="handleVideoLoaded"
4140
@timeupdate="updateCurrentChapter"
4241
@ended="handleVideoEnded"
43-
@reset-autoplay-interruption-timeout="resetAutoplayInterruptionTimeout"
4442
@toggle-theatre-mode="useTheatreMode = !useTheatreMode"
4543
/>
4644
<div

static/locales/en-US.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,7 @@ Playlist will not pause when current video is finished: Playlist will not pause
10961096
Playlist will pause when current video is finished: Playlist will pause when current video is finished
10971097
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.
10981098
Canceled next video autoplay: Canceled next video autoplay
1099+
Canceled next video autoplay due to inactivity: Canceled next video autoplay due to inactivity
10991100

11001101
Default Invidious instance has been set to {instance}: Default Invidious instance has been set to {instance}
11011102
Default Invidious instance has been cleared: Default Invidious instance has been cleared

0 commit comments

Comments
 (0)