windows can have their artwork
This commit is contained in:
parent
5d43c3b27c
commit
d939914ea7
1 changed files with 19 additions and 10 deletions
|
@ -1,6 +1,8 @@
|
||||||
import fetch from "electron-fetch";
|
import fetch from "electron-fetch";
|
||||||
import {nativeImage, Notification} from "electron";
|
import {app, nativeImage, Notification} from "electron";
|
||||||
import NativeImage = Electron.NativeImage;
|
import NativeImage = Electron.NativeImage;
|
||||||
|
import {createWriteStream} from "fs";
|
||||||
|
import {join} from "path";
|
||||||
|
|
||||||
export default class playbackNotifications {
|
export default class playbackNotifications {
|
||||||
|
|
||||||
|
@ -44,7 +46,8 @@ export default class playbackNotifications {
|
||||||
<toast>
|
<toast>
|
||||||
<audio silent="true" />
|
<audio silent="true" />
|
||||||
<visual>
|
<visual>
|
||||||
<binding template="ToastText02">
|
<binding template="ToastImageAndText02">
|
||||||
|
<image id="1" src="${join(app.getPath("temp"), `${a.songId}-${a.artwork.url.split('/').pop()}`)}" name="Image" />
|
||||||
<text id="1">${a?.name.replace(/&/g, '&')}</text>
|
<text id="1">${a?.name.replace(/&/g, '&')}</text>
|
||||||
<text id="2">${a?.artistName.replace(/&/g, '&')} — ${a?.albumName.replace(/&/g, '&')}</text>
|
<text id="2">${a?.artistName.replace(/&/g, '&')} — ${a?.albumName.replace(/&/g, '&')}</text>
|
||||||
</binding>
|
</binding>
|
||||||
|
@ -56,9 +59,6 @@ export default class playbackNotifications {
|
||||||
</toast>`
|
</toast>`
|
||||||
});
|
});
|
||||||
|
|
||||||
// image implementation in windows toasts
|
|
||||||
//<image id="1" src="path to image" alt="img"/>
|
|
||||||
|
|
||||||
this._notification.on('click', (_: any) => {
|
this._notification.on('click', (_: any) => {
|
||||||
this._utils.getWindow().show()
|
this._utils.getWindow().show()
|
||||||
this._utils.getWindow().focus()
|
this._utils.getWindow().focus()
|
||||||
|
@ -99,11 +99,20 @@ export default class playbackNotifications {
|
||||||
if (this._artworkImage[a.artwork.url]) {
|
if (this._artworkImage[a.artwork.url]) {
|
||||||
this.createNotification(a);
|
this.createNotification(a);
|
||||||
} else {
|
} else {
|
||||||
fetch(a.artwork.url).then(async blob => {
|
if (process.platform === "win32") {
|
||||||
this._artworkImage[a.artwork.url] = nativeImage.createFromBuffer(Buffer.from(await blob.arrayBuffer()));
|
fetch(a.artwork.url)
|
||||||
this._artworkNums[this._artworkNums.length] = a.artwork.url;
|
.then(res => {
|
||||||
this.createNotification(a);
|
const dest = createWriteStream(join(app.getPath("temp"), `${a.songId}-${a.artwork.url.split('/').pop()}`));
|
||||||
});
|
// @ts-ignore
|
||||||
|
res.body.pipe(dest)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fetch(a.artwork.url).then(async blob => {
|
||||||
|
this._artworkImage[a.artwork.url] = nativeImage.createFromBuffer(Buffer.from(await blob.arrayBuffer()));
|
||||||
|
this._artworkNums[this._artworkNums.length] = a.artwork.url;
|
||||||
|
this.createNotification(a);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue