diff --git a/src/components/MediaWidget/PlaylistController.ts b/src/components/MediaWidget/PlaylistController.ts index 13cd5c9..7a9b178 100644 --- a/src/components/MediaWidget/PlaylistController.ts +++ b/src/components/MediaWidget/PlaylistController.ts @@ -16,12 +16,12 @@ export class PlaylistController { constructor(recipientId: string, widgetId: string, conf: any) { this.recipientId = recipientId; - const requested = new Playlist(PLAYLIST_TYPE.REQUESTED); + const requested = new Playlist(PLAYLIST_TYPE.REQUESTED, conf.topic.player); this.current = requested; this.playlists.set(PLAYLIST_TYPE.REQUESTED, requested); this.playlists.set( PLAYLIST_TYPE.PERSONAL, - new Playlist(PLAYLIST_TYPE.PERSONAL), + new Playlist(PLAYLIST_TYPE.PERSONAL, conf.topic.player), ); log.info(`Loading playlist for ${recipientId}`); diff --git a/src/components/PlayerInfo/PlayerInfo.tsx b/src/components/PlayerInfo/PlayerInfo.tsx index 13cb246..9f3d3e2 100644 --- a/src/components/PlayerInfo/PlayerInfo.tsx +++ b/src/components/PlayerInfo/PlayerInfo.tsx @@ -18,7 +18,7 @@ function PlayerInfo() { subscribe(widgetId, conf.topic.player, (message) => { log.debug(`Received: ${message.body}`); let json = JSON.parse(message.body); - if (json.title) { + if (json.title !== null) { setTitle(json.title); } if (json.count != null && json.number != null) { diff --git a/src/logic/playlist/Playlist.ts b/src/logic/playlist/Playlist.ts index 1251882..60bd516 100644 --- a/src/logic/playlist/Playlist.ts +++ b/src/logic/playlist/Playlist.ts @@ -1,6 +1,7 @@ import { markListened } from "../../components/MediaWidget/api"; import { Song } from "../../components/MediaWidget/types"; import { log } from "../../logging"; +import { publish } from "../../socket"; import { IPlaylistChangesListener } from "./PlaylistChangesListener"; enum PLAYLIST_TYPE { @@ -13,9 +14,11 @@ class Playlist { _index: number | null = null; _type: PLAYLIST_TYPE; _listeners: IPlaylistChangesListener[] = []; + topic: string; - constructor(type: PLAYLIST_TYPE) { + constructor(type: PLAYLIST_TYPE, topic: string) { this._type = type; + this.topic = topic; } addSong(song: Song) { @@ -131,6 +134,10 @@ class Playlist { } triggerListeners() { + publish(this.topic, { + count: this._index === null ? 0 : this._songs.length, + number: this._index === null ? 0 : this._index + }); this._listeners.forEach((listener) => listener.trigger(this)); } }