Skip to content

Commit

Permalink
fix(web): fix issues with repeat mode and track add logic (#2291)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram-dc authored Apr 17, 2024
1 parent ef0e750 commit 6c4a3bd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web/TrackPlayer/PlaylistPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class PlaylistPlayer extends Player {
case RepeatMode.Playlist:
if (this.currentIndex === this.playlist.length - 1) {
await this.goToIndex(0);
} else {
await this.skipToNext();
}
break;
default:
Expand All @@ -38,7 +40,6 @@ export class PlaylistPlayer extends Player {
if ((err as Error).message !== 'playlist_exhausted') {
throw err;
}

this.onPlaylistEnded();
}
break;
Expand Down Expand Up @@ -79,7 +80,7 @@ export class PlaylistPlayer extends Player {
}

public async add(tracks: Track[], insertBeforeIndex?: number) {
if (insertBeforeIndex) {
if (insertBeforeIndex !== -1 && insertBeforeIndex !== undefined) {
this.playlist.splice(insertBeforeIndex, 0, ...tracks);
} else {
this.playlist.push(...tracks);
Expand Down

0 comments on commit 6c4a3bd

Please sign in to comment.