forked from Blendman974/faceclaw
Fix a bug where album art and track info could get out of sync if you advance twice quickly
This commit is contained in:
1 parent
eb91d46657
commit
13da595de0
6 files changed
+38
-13
No files matched your search
@@ -49,7 +49,8 @@ export class MusicWidget implements GlanceWidget {
|
||||
private unsubscribe: (() => void) | null = null;
|
||||
private progressTimer: ReturnType<typeof setInterval> | null = null;
|
||||
private art: GrayImage | null = null;
|
||||
private artKey = "";
|
||||
/** The artVersion `art` was fetched for; -1 = not fetched yet. */
|
||||
private artVersion = -1;
|
||||
|
||||
start(requestRender: () => void): void {
|
||||
this.unsubscribe = mediaControllerBridge.onStateChange((state) => {
|
||||
@@ -129,10 +130,8 @@ export class MusicWidget implements GlanceWidget {
|
||||
}
|
||||
|
||||
private drawArt(image: GrayImage, media: MediaControllerState, artY: number): void {
|
||||
const key = `${media.packageName}|${media.title}|${media.album}`;
|
||||
// Retry while null: players often publish metadata before the bitmap.
|
||||
if (key !== this.artKey || this.art === null) {
|
||||
this.artKey = key;
|
||||
if (media.artVersion !== this.artVersion) {
|
||||
this.artVersion = media.artVersion;
|
||||
this.art = mediaControllerBridge.getAlbumArt(ART_SIZE);
|
||||
}
|
||||
if (this.art) {
|
||||
|
||||
Reference in new issue
Block a user