From 6591f61185fd252691539bfb813e36cc63204d69 Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:33:52 +1100 Subject: [PATCH] Display content only if player is idle This ensures content is not displayed on screen if player is buffering. --- src/components/commandHandler.ts | 2 +- src/components/playbackManager.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/commandHandler.ts b/src/components/commandHandler.ts index 6c070119..80dad7d2 100644 --- a/src/components/commandHandler.ts +++ b/src/components/commandHandler.ts @@ -83,7 +83,7 @@ export abstract class CommandHandler { } static displayContentHandler(data: DataMessage): void { - if (!PlaybackManager.isPlaying()) { + if (PlaybackManager.isIdle()) { DocumentManager.showItemId((data.options as DisplayRequest).ItemId); } } diff --git a/src/components/playbackManager.ts b/src/components/playbackManager.ts index b0406c9d..0c24e908 100644 --- a/src/components/playbackManager.ts +++ b/src/components/playbackManager.ts @@ -104,6 +104,13 @@ export abstract class PlaybackManager { ); } + static isIdle(): boolean { + return ( + this.playerManager.getPlayerState() === + cast.framework.messages.PlayerState.IDLE + ); + } + static async playFromOptions(options: PlayRequest): Promise { const firstItem = options.items[0];