mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-28 04:11:57 +01:00
Keep a tighter sync between Jellyfin's remote control and the state of the Discord player (#256)
* Keep a tighter sync between Jellyfin's remote control and the state of the Discord player * Fix accidental omission
This commit is contained in:
parent
390c6f145f
commit
941bc8745e
@ -129,6 +129,10 @@ export class DiscordVoiceService {
|
|||||||
@OnEvent('internal.voice.controls.pause')
|
@OnEvent('internal.voice.controls.pause')
|
||||||
pause() {
|
pause() {
|
||||||
this.createAndReturnOrGetAudioPlayer().pause();
|
this.createAndReturnOrGetAudioPlayer().pause();
|
||||||
|
const track = this.playbackService.getPlaylistOrDefault().getActiveTrack();
|
||||||
|
if(track) {
|
||||||
|
track.playing = false;
|
||||||
|
}
|
||||||
this.eventEmitter.emit('playback.state.pause', true);
|
this.eventEmitter.emit('playback.state.pause', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +141,13 @@ export class DiscordVoiceService {
|
|||||||
*/
|
*/
|
||||||
@OnEvent('internal.voice.controls.stop')
|
@OnEvent('internal.voice.controls.stop')
|
||||||
stop(force: boolean): boolean {
|
stop(force: boolean): boolean {
|
||||||
return this.createAndReturnOrGetAudioPlayer().stop(force);
|
const hasStopped = this.createAndReturnOrGetAudioPlayer().stop(force);
|
||||||
|
if (hasStopped) {
|
||||||
|
const playlist = this.playbackService.getPlaylistOrDefault();
|
||||||
|
this.eventEmitter.emit('internal.audio.track.finish', playlist.getActiveTrack());
|
||||||
|
playlist.clear();
|
||||||
|
}
|
||||||
|
return hasStopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,6 +155,10 @@ export class DiscordVoiceService {
|
|||||||
*/
|
*/
|
||||||
unpause() {
|
unpause() {
|
||||||
this.createAndReturnOrGetAudioPlayer().unpause();
|
this.createAndReturnOrGetAudioPlayer().unpause();
|
||||||
|
const track = this.playbackService.getPlaylistOrDefault().getActiveTrack();
|
||||||
|
if(track) {
|
||||||
|
track.playing = true;
|
||||||
|
}
|
||||||
this.eventEmitter.emit('playback.state.pause', false);
|
this.eventEmitter.emit('playback.state.pause', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +97,9 @@ export class JellyinPlaystateService {
|
|||||||
|
|
||||||
@Interval(1000)
|
@Interval(1000)
|
||||||
private async onPlaybackProgress() {
|
private async onPlaybackProgress() {
|
||||||
const track = this.playbackService.getPlaylistOrDefault().getActiveTrack();
|
const playlist = this.playbackService.getPlaylistOrDefault();
|
||||||
|
const track = playlist.getActiveTrack();
|
||||||
if (!track) {
|
if (!track || !playlist.hasAnyPlaying()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ export class Playlist {
|
|||||||
this.activeTrackIndex = undefined;
|
this.activeTrackIndex = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
private hasAnyPlaying() {
|
hasAnyPlaying() {
|
||||||
return this.tracks.some((track) => track.playing);
|
return this.tracks.some((track) => track.playing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user