|
5 | 5 | Player as PlayerService,
|
6 | 6 | type Album,
|
7 | 7 | type PlayerState,
|
| 8 | + type Track, |
8 | 9 | } from "@echo/core-types";
|
9 | 10 | import { Match, Option } from "effect";
|
10 | 11 | import { EffectFn } from "@echo/components-shared-controllers/src/effect-fn.controller";
|
@@ -90,35 +91,30 @@ export class EchoPlayer extends LitElement {
|
90 | 91 | { album, trackIndex }: { album: Album; trackIndex: number },
|
91 | 92 | ) {
|
92 | 93 | 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); |
100 | 95 | }
|
101 | 96 |
|
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) { |
108 | 98 | 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) |
111 | 107 | ? html` <img
|
112 | 108 | id="current-track-cover"
|
113 |
| - src="${URL.createObjectURL(cover.value)}" |
| 109 | + src="${URL.createObjectURL(album.embeddedCover.value)}" |
114 | 110 | height="40"
|
115 | 111 | width="40"
|
116 | 112 | alt="Album cover"
|
117 | 113 | />`
|
118 | 114 | : nothing}
|
119 | 115 | <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> |
122 | 118 | </div>
|
123 | 119 | ${player.status._tag !== "Stopped"
|
124 | 120 | ? html`
|
|
0 commit comments