+ {i}
+
+
+ {track?.title}
+
+ {track.artist && (
+
+ by
+
+ {track.artist}
+
+
+ )}
+ {track.album && (
+
+ on
+
+ {track.album}
+
+
+ )}
+
+
+ );
+}
+
+export function YtmPlayer() {
+ const track = useStateFromStores(
+ [YoutubeMusicStore],
+ () => YoutubeMusicStore.song,
+ null,
+ (prev, next) => prev?.videoId ? (prev.videoId === next?.videoId) : prev?.title === next?.title
+ );
+
+ const isPlaying = useStateFromStores([YoutubeMusicStore], () => YoutubeMusicStore.isPlaying);
+ const [shouldHide, setShouldHide] = useState(false);
+
+
+ React.useEffect(() => {
+ setShouldHide(false);
+ if (!isPlaying) {
+ const timeout = setTimeout(() => setShouldHide(true), 1000 * 60 * 5);
+ return () => clearTimeout(timeout);
+ }
+ }, [isPlaying]);
+
+ if (!track || shouldHide) return;
+
+ const exportTrackImageStyle = {
+ "--vc-ytm-track-image": `url(${track?.imageSrc || ""})`,
+ } as React.CSSProperties;
+
+ return (
+