Skip to content

Commit 17c56c9

Browse files
committed
Artist, album and track info on data tags
This will come in handy for supporting the app on WebScrobbler
1 parent 2d43da9 commit 17c56c9

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

packages/components/player/src/player.ts

+14-18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Player as PlayerService,
66
type Album,
77
type PlayerState,
8+
type Track,
89
} from "@echo/core-types";
910
import { Match, Option } from "effect";
1011
import { EffectFn } from "@echo/components-shared-controllers/src/effect-fn.controller";
@@ -90,35 +91,30 @@ export class EchoPlayer extends LitElement {
9091
{ album, trackIndex }: { album: Album; trackIndex: number },
9192
) {
9293
const track = album.tracks[trackIndex];
93-
94-
return this._renderPlayer(
95-
player,
96-
album.embeddedCover,
97-
track.mainArtist.name,
98-
track.name,
99-
);
94+
return this._renderPlayer(player, album, track);
10095
}
10196

102-
private _renderPlayer(
103-
player: PlayerState,
104-
cover: Album["embeddedCover"],
105-
artistName: string,
106-
trackName: string,
107-
) {
97+
private _renderPlayer(player: PlayerState, album: Album, track: Track) {
10898
return html`
109-
<div id="player" class="current-track">
110-
${Option.isSome(cover)
99+
<div
100+
id="player"
101+
class="current-track"
102+
data-album-name=${album.name}
103+
data-artist-name=${track.mainArtist.name}
104+
data-track-name=${track.name}
105+
>
106+
${Option.isSome(album.embeddedCover)
111107
? html` <img
112108
id="current-track-cover"
113-
src="${URL.createObjectURL(cover.value)}"
109+
src="${URL.createObjectURL(album.embeddedCover.value)}"
114110
height="40"
115111
width="40"
116112
alt="Album cover"
117113
/>`
118114
: nothing}
119115
<div class="track-info">
120-
<h4 id="track-name">${trackName}</h4>
121-
<h6 id="artist-name">${artistName}</h6>
116+
<h4 id="track-name">${track.name}</h4>
117+
<h6 id="artist-name">${track.mainArtist.name}</h6>
122118
</div>
123119
${player.status._tag !== "Stopped"
124120
? html`

0 commit comments

Comments
 (0)