Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canva update #74

Merged
merged 21 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix to show canva when start player
  • Loading branch information
dientuki committed May 1, 2024
commit 2017ffeaa880338d32496e45eb9be9fa96ca1ba8
14 changes: 8 additions & 6 deletions MMM-OnSpotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ Module.register("MMM-OnSpotify", {

smartUpdate: function (type) {
// Request data to display when the player is empty
// Update only if there is no data or the player is changing state
// Update only if there is no data or the player is changing state

this.requestUserData =
this.displayUser &&
this.isConnectedToSpotify &&
Expand Down Expand Up @@ -597,6 +598,10 @@ Module.register("MMM-OnSpotify", {
this.lastStatus = this.currentStatus;
}

if (type === "CANVAS") {
this.builder.updateCanvasData(this.canvasData);
}

if (this.currentStatus === "onReconnecting") {
this.retries = this.retries > 25 ? this.retries : this.retries + 1;
if (this.retries === 25) {
Expand All @@ -623,7 +628,7 @@ Module.register("MMM-OnSpotify", {
return;
} else {
this.retries = 0;
}
}

if (
this.playerData &&
Expand Down Expand Up @@ -662,10 +667,7 @@ Module.register("MMM-OnSpotify", {
}
if (type === "USER_DATA") this.builder.updateUserData(this.userData);
if (type === "AFFINITY_DATA")
this.builder.updateAffinityData(this.affinityData);
if (type === "CANVAS") {
this.builder.updateCanvasData(this.canvasData);
}
this.builder.updateAffinityData(this.affinityData);
},

getImage: (im, prefersLarge) =>
Expand Down
11 changes: 10 additions & 1 deletion utils/SpotifyDomBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class SpotifyDomBuilder {
spotifyLogoGreen: "assets/spotifyLogoGreen.png",
spotifyLogoWide: "assets/spotifyLogoWide.png",
};
this.tmpCanva = null;
}

/* All cases */
Expand Down Expand Up @@ -446,6 +447,10 @@ class SpotifyDomBuilder {
video.autobuffer = true;
video.autoplay = true;
video.loop = true;
if (this.tmpCanva != null) {
video.src = this.tmpCanva;
this.tmpCanva = null;
}
mycanvas.appendChild(video);

player.appendChild(mycanvas);
Expand Down Expand Up @@ -483,7 +488,11 @@ class SpotifyDomBuilder {

updateCanvasData(data) {
const vid = document.getElementById("VSNO-TARGET-VIDEO");
vid.src = data != null ? data : '';
if (vid == null) {
this.tmpCanva = data;
} else {
vid.src = data != null ? data : '';
}
}

updatePlayerData(data) {
Expand Down