mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-09 05:09:39 +00:00
27 lines
644 B
TypeScript
27 lines
644 B
TypeScript
import { Injectable } from '@angular/core'
|
|
|
|
import { ElectronService } from './electron.service'
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class AlbumArtService {
|
|
|
|
private imageCache: { [songID: number]: string } = {}
|
|
|
|
constructor(private electronService: ElectronService) { }
|
|
|
|
async getImage(songID: number): Promise<string | null> {
|
|
if (this.imageCache[songID] == undefined) {
|
|
const albumArtResult = await this.electronService.invoke('album-art', songID)
|
|
if (albumArtResult) {
|
|
this.imageCache[songID] = albumArtResult.base64Art
|
|
} else {
|
|
this.imageCache[songID] = null
|
|
}
|
|
}
|
|
|
|
return this.imageCache[songID]
|
|
}
|
|
}
|