Fix for NPE when playerState is null (#14191)

Signed-off-by: Mark Hilbush <mark@hilbush.com>
This commit is contained in:
Mark Hilbush 2023-01-10 09:02:40 -05:00 committed by Jacob Laursen
parent 551cd8f41d
commit e392f7f3bf

View File

@ -157,30 +157,32 @@ public class ChromecastStatusUpdater {
return;
}
switch (mediaStatus.playerState) {
case IDLE:
break;
case PAUSED:
callback.updateState(CHANNEL_CONTROL, PlayPauseType.PAUSE);
callback.updateState(CHANNEL_STOP, OnOffType.OFF);
break;
case BUFFERING:
case LOADING:
case PLAYING:
callback.updateState(CHANNEL_CONTROL, PlayPauseType.PLAY);
callback.updateState(CHANNEL_STOP, OnOffType.OFF);
break;
default:
logger.debug("Unknown media status: {}", mediaStatus.playerState);
break;
if (mediaStatus.playerState != null) {
switch (mediaStatus.playerState) {
case IDLE:
break;
case PAUSED:
callback.updateState(CHANNEL_CONTROL, PlayPauseType.PAUSE);
callback.updateState(CHANNEL_STOP, OnOffType.OFF);
break;
case BUFFERING:
case LOADING:
case PLAYING:
callback.updateState(CHANNEL_CONTROL, PlayPauseType.PLAY);
callback.updateState(CHANNEL_STOP, OnOffType.OFF);
break;
default:
logger.debug("Unknown media status: {}", mediaStatus.playerState);
break;
}
}
callback.updateState(CHANNEL_CURRENT_TIME, new QuantityType<>(mediaStatus.currentTime, Units.SECOND));
// If we're playing, paused or buffering but don't have any MEDIA information don't null everything out.
Media media = mediaStatus.media;
if (media == null && (mediaStatus.playerState == PLAYING || mediaStatus.playerState == PAUSED
|| mediaStatus.playerState == BUFFERING)) {
if (media == null && (mediaStatus.playerState == null || mediaStatus.playerState == PLAYING
|| mediaStatus.playerState == PAUSED || mediaStatus.playerState == BUFFERING)) {
return;
}