[chromecast] Fix STOP command

Fixes #14516

Signed-off-by: lsiepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2023-08-01 21:22:37 +02:00 committed by GitHub
parent 72028f7a86
commit 5a447375a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,7 +128,18 @@ public class ChromecastCommander {
public void handleCloseApp(final Command command) { public void handleCloseApp(final Command command) {
if (command == OnOffType.ON) { if (command == OnOffType.ON) {
closeApp(MEDIA_PLAYER); Application app;
try {
app = chromeCast.getRunningApp();
} catch (final IOException e) {
logger.info("{} command failed: {}", command, e.getMessage());
statusUpdater.updateStatus(ThingStatus.OFFLINE, COMMUNICATION_ERROR, e.getMessage());
return;
}
if (app != null) {
closeApp(app.id);
}
} }
} }
@ -250,13 +261,13 @@ public class ChromecastCommander {
try { try {
if (chromeCast.isAppRunning(appId)) { if (chromeCast.isAppRunning(appId)) {
Application app = chromeCast.getRunningApp(); Application app = chromeCast.getRunningApp();
if (app.id.equals(appId) && app.sessionId.equals(statusUpdater.getAppSessionId())) { if (app.id.equals(appId)) {
chromeCast.stopApp(); chromeCast.stopApp();
logger.debug("Application closed: {}", appId); logger.debug("Application closed: {}", appId);
} }
} }
} catch (final IOException e) { } catch (final IOException e) {
logger.debug("Failed stopping media player app: {} with message: {}", appId, e.getMessage()); logger.debug("Failed stopping app: {} with message: {}", appId, e.getMessage());
} }
} }