Skip to content

Commit

Permalink
Fix Cast demo (#3460)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Aug 6, 2019
1 parent 98b882d commit aca5ae9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion demo/src/custom-cards/cast-demo-row.ts
Expand Up @@ -54,7 +54,12 @@ class CastDemoRow extends LitElement implements EntityRow {
mgr.castContext.addEventListener(
cast.framework.CastContextEventType.SESSION_STATE_CHANGED,
(ev) => {
if (ev.sessionState === "SESSION_STARTED") {
// On Android, opening a new session always results in SESSION_RESUMED.
// So treat both as the same.
if (
ev.sessionState === "SESSION_STARTED" ||
ev.sessionState === "SESSION_RESUMED"
) {
castSendShowDemo(mgr);
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/cast/cast_manager.ts
Expand Up @@ -122,10 +122,12 @@ export class CastManager {
if (__DEV__) {
console.log("Cast session state changed", ev.sessionState);
}
if (ev.sessionState === "SESSION_RESUMED") {
this.sendMessage({ type: "get_status" });
this._attachMessageListener();
} else if (ev.sessionState === "SESSION_STARTED") {
// On Android, opening a new session always results in SESSION_RESUMED.
// So treat both as the same.
if (
ev.sessionState === "SESSION_STARTED" ||
ev.sessionState === "SESSION_RESUMED"
) {
if (this.auth) {
castSendAuth(this, this.auth);
} else {
Expand Down

0 comments on commit aca5ae9

Please sign in to comment.