@samitouri / QOSami-HFS / commits / eae25bf6

file-show: system integration showing file-name and artwork (if any is found in the same folder)

Massimo Melina committed Jan 31, 2024 at 23:15 UTC eae25bf6d70513e03e45a12900eb31412033094d
1 file changed +10 -1
frontend/src/show.ts
+10 -1
@@ -130,7 +130,16 @@ export function fileShow(entry: DirEntry) {
130 lastGood.current = cur
131 setLoading(false)
132 },
133 - onError: curFailed
133 + onError: curFailed,
134 + onPlay() {
135 + const folder = cur.n.slice(0, -cur.name)
136 + navigator.mediaSession.metadata = new MediaMetadata({
137 + title: cur.name,
138 + artwork: state.list.filter(x => folder === x.n.slice(0, -x.name) // same folder
139 + && x.name.match(/(?:folder|cover|albumart.*)\.jpe?g$/i))
140 + .map(x => ({ src: x.n }))
141 + })
142 + }
143 })
144 ),
145 hIcon('❮', { className: navClass, style: { left: 0 }, onClick: goPrev }),