mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
🐛 Crash with nextTrack and previousTrack
This commit is contained in:
parent
60df58959a
commit
2571c71184
@ -19,6 +19,7 @@ export class PlaybackService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setActiveTrack(trackId: string) {
|
setActiveTrack(trackId: string) {
|
||||||
|
console.log(`getting track by id ${trackId}`);
|
||||||
const track = this.getTrackById(trackId);
|
const track = this.getTrackById(trackId);
|
||||||
|
|
||||||
if (!track) {
|
if (!track) {
|
||||||
@ -30,12 +31,15 @@ export class PlaybackService {
|
|||||||
|
|
||||||
nextTrack() {
|
nextTrack() {
|
||||||
const keys = this.getTrackIds();
|
const keys = this.getTrackIds();
|
||||||
|
console.log('keys:');
|
||||||
|
console.log(keys);
|
||||||
|
|
||||||
const index = this.getActiveIndex();
|
const index = this.getActiveIndex();
|
||||||
|
|
||||||
console.log(keys);
|
console.log(keys);
|
||||||
console.log(index);
|
console.log(index);
|
||||||
|
|
||||||
if (!this.hasActiveTrack() || index >= keys.length) {
|
if (!this.hasActiveTrack() || index + 1 >= keys.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +109,7 @@ export class PlaybackService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getTrackIds() {
|
private getTrackIds() {
|
||||||
return Object.keys(this.playlist.tracks);
|
return this.playlist.tracks.map((item) => item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getActiveIndex() {
|
private getActiveIndex() {
|
||||||
@ -114,8 +118,6 @@ export class PlaybackService {
|
|||||||
|
|
||||||
private controlAudioPlayer() {
|
private controlAudioPlayer() {
|
||||||
const activeTrack = this.getActiveTrack();
|
const activeTrack = this.getActiveTrack();
|
||||||
console.log('received track change');
|
|
||||||
console.log(activeTrack.track);
|
|
||||||
this.eventEmitter.emit('playback.newTrack', activeTrack.track);
|
this.eventEmitter.emit('playback.newTrack', activeTrack.track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user