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 GitHub
parent 72786df044
commit 65816aafd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}