mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
✨ Add websocket playback control for next and previous
This commit is contained in:
parent
65d401fdbb
commit
831e03a77f
@ -113,9 +113,6 @@ export class JellyfinWebSocketService implements OnModuleDestroy {
|
||||
msg.Data as SessionApiSendPlaystateCommandRequest;
|
||||
this.handleSendPlaystateCommandRequest(sendPlaystateCommandRequest);
|
||||
break;
|
||||
case SessionMessageType[SessionMessageType.UserDataChanged]:
|
||||
this.logger.debug("Received update for user session data");
|
||||
break;
|
||||
default:
|
||||
this.logger.warn(
|
||||
`Received a package from the socket of unknown type: ${msg.MessageType}`,
|
||||
@ -129,13 +126,19 @@ export class JellyfinWebSocketService implements OnModuleDestroy {
|
||||
) {
|
||||
switch (request.Command) {
|
||||
case PlaystateCommand.PlayPause:
|
||||
this.eventEmitter.emitAsync('internal.voice.controls.togglePause');
|
||||
this.eventEmitter.emit('internal.voice.controls.togglePause');
|
||||
break;
|
||||
case PlaystateCommand.Pause:
|
||||
this.eventEmitter.emitAsync('internal.voice.controls.pause');
|
||||
this.eventEmitter.emit('internal.voice.controls.pause');
|
||||
break;
|
||||
case PlaystateCommand.Stop:
|
||||
this.eventEmitter.emitAsync('internal.voice.controls.stop');
|
||||
this.eventEmitter.emit('internal.voice.controls.stop');
|
||||
break;
|
||||
case PlaystateCommand.NextTrack:
|
||||
this.eventEmitter.emit('internal.audio.track.next');
|
||||
break;
|
||||
case PlaystateCommand.PreviousTrack:
|
||||
this.eventEmitter.emit('internal.audio.track.previous');
|
||||
break;
|
||||
default:
|
||||
this.logger.warn(
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { EventEmitter2, OnEvent } from '@nestjs/event-emitter';
|
||||
|
||||
import { Track } from './Track';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { EventEmitter2, OnEvent } from '@nestjs/event-emitter';
|
||||
|
||||
import { Playlist } from '../models/shared/Playlist';
|
||||
|
||||
@ -18,4 +18,14 @@ export class PlaybackService {
|
||||
this.playlist = new Playlist(this.eventEmitter);
|
||||
return this.playlist;
|
||||
}
|
||||
|
||||
@OnEvent('internal.audio.track.previous')
|
||||
private handlePreviousTrackEvent() {
|
||||
this.getPlaylistOrDefault().setPreviousTrackAsActiveTrack();
|
||||
}
|
||||
|
||||
@OnEvent('internal.audio.track.next')
|
||||
private handleNextTrackEvent() {
|
||||
this.getPlaylistOrDefault().setNextTrackAsActiveTrack();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user