mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
🐛 Fix track state on finishing track
This commit is contained in:
parent
00e58dcc8d
commit
b940ca98e2
@ -266,6 +266,7 @@ export class DiscordVoiceService {
|
|||||||
|
|
||||||
const playlist = this.playbackService.getPlaylistOrDefault();
|
const playlist = this.playbackService.getPlaylistOrDefault();
|
||||||
const finishedTrack = playlist.getActiveTrack();
|
const finishedTrack = playlist.getActiveTrack();
|
||||||
|
finishedTrack.playing = false;
|
||||||
|
|
||||||
this.eventEmitter.emit('internal.audio.track.finish', finishedTrack);
|
this.eventEmitter.emit('internal.audio.track.finish', finishedTrack);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import { getSessionApi } from '@jellyfin/sdk/lib/utils/api/session-api';
|
|||||||
|
|
||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { OnEvent } from '@nestjs/event-emitter';
|
import { OnEvent } from '@nestjs/event-emitter';
|
||||||
import { Track } from 'src/models/shared/Track';
|
import { Track } from '../../models/shared/Track';
|
||||||
|
|
||||||
import { PlaybackService } from '../../playback/playback.service';
|
import { PlaybackService } from '../../playback/playback.service';
|
||||||
|
|
||||||
|
@ -92,12 +92,21 @@ export class Playlist {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const previousTrackLength = this.tracks.length;
|
||||||
|
|
||||||
this.eventEmitter.emit('controls.playlist.tracks.enqueued', {
|
this.eventEmitter.emit('controls.playlist.tracks.enqueued', {
|
||||||
count: tracks.length,
|
count: tracks.length,
|
||||||
activeTrack: this.activeTrackIndex,
|
activeTrack: this.activeTrackIndex,
|
||||||
});
|
});
|
||||||
const length = this.tracks.push(...tracks);
|
const length = this.tracks.push(...tracks);
|
||||||
|
|
||||||
|
// existing tracks are in the playlist, but none are playing. play the first track out of the new tracks
|
||||||
|
if (!this.hasAnyPlaying() && tracks.length > 0) {
|
||||||
|
this.activeTrackIndex = previousTrackLength;
|
||||||
|
this.announceTrackChange();
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
// emit a track change if there is no item
|
// emit a track change if there is no item
|
||||||
if (this.activeTrackIndex === undefined) {
|
if (this.activeTrackIndex === undefined) {
|
||||||
this.announceTrackChange();
|
this.announceTrackChange();
|
||||||
@ -128,6 +137,10 @@ export class Playlist {
|
|||||||
this.activeTrackIndex = undefined;
|
this.activeTrackIndex = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private hasAnyPlaying() {
|
||||||
|
return this.tracks.some((track) => track.playing);
|
||||||
|
}
|
||||||
|
|
||||||
private announceTrackFinishIfSet() {
|
private announceTrackFinishIfSet() {
|
||||||
if (this.activeTrackIndex === undefined) {
|
if (this.activeTrackIndex === undefined) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user