From 2571c7118496d9ad579561914780fe8c57462b47 Mon Sep 17 00:00:00 2001 From: Manuel Ruwe Date: Sat, 17 Dec 2022 20:27:05 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Crash=20with=20nextTrack=20and?= =?UTF-8?q?=20previousTrack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/playback/playback.service.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/playback/playback.service.ts b/src/playback/playback.service.ts index 27cc2cb..62e0f29 100644 --- a/src/playback/playback.service.ts +++ b/src/playback/playback.service.ts @@ -19,6 +19,7 @@ export class PlaybackService { } setActiveTrack(trackId: string) { + console.log(`getting track by id ${trackId}`); const track = this.getTrackById(trackId); if (!track) { @@ -30,12 +31,15 @@ export class PlaybackService { nextTrack() { const keys = this.getTrackIds(); + console.log('keys:'); + console.log(keys); + const index = this.getActiveIndex(); console.log(keys); console.log(index); - if (!this.hasActiveTrack() || index >= keys.length) { + if (!this.hasActiveTrack() || index + 1 >= keys.length) { return false; } @@ -105,7 +109,7 @@ export class PlaybackService { } private getTrackIds() { - return Object.keys(this.playlist.tracks); + return this.playlist.tracks.map((item) => item.id); } private getActiveIndex() { @@ -114,8 +118,6 @@ export class PlaybackService { private controlAudioPlayer() { const activeTrack = this.getActiveTrack(); - console.log('received track change'); - console.log(activeTrack.track); this.eventEmitter.emit('playback.newTrack', activeTrack.track); } }