Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix fallback on invalid previous video

Chocobozzz3f6d36ed758e
diff --git a/client/src/standalone/videos/shared/playlist-tracker.ts b/client/src/standalone/videos/shared/playlist-tracker.ts
index dc9a084b7a..5830f6a4cd 100644
--- a/client/src/standalone/videos/shared/playlist-tracker.ts
+++ b/client/src/standalone/videos/shared/playlist-tracker.ts
@@ -8,7 +8,6 @@ export class PlaylistTracker {
private readonly playlist: VideoPlaylist,
private readonly playlistElements: VideoPlaylistElement[]
) {
-
}
getPlaylist () {
@@ -53,7 +52,7 @@ export class PlaylistTracker {
const prev = this.playlistElements.find(e => e.position === position)
if (!prev?.video) {
- return this.getNextPlaylistElement(position - 1)
+ return this.getPreviousPlaylistElement(position - 1)
}
return prev
@@ -68,14 +67,15 @@ export class PlaylistTracker {
setPosition (position: number) {
this.currentPlaylistElement = this.playlistElements.find(e => e.position === position)
- if (!this.currentPlaylistElement?.video) {
- logger.error('Current playlist element is not valid.', this.currentPlaylistElement)
- this.currentPlaylistElement = this.getNextPlaylistElement()
- }
if (!this.currentPlaylistElement) {
throw new Error('This playlist does not have any valid element')
}
+
+ if (!this.currentPlaylistElement?.video) {
+ logger.error('Current playlist element is not valid.', this.currentPlaylistElement)
+ this.currentPlaylistElement = this.getNextPlaylistElement()
+ }
}
setCurrentElement (playlistElement: VideoPlaylistElement) {