Spaces:
Sleeping
Sleeping
File size: 1,165 Bytes
21986a1 ba6c831 21986a1 f57be92 21986a1 11c56f5 eb2c7d1 f57be92 11c56f5 ba6c831 f57be92 21986a1 eb2c7d1 ba6c831 eb2c7d1 ba6c831 21986a1 ba6c831 f57be92 11c56f5 21986a1 eb2c7d1 ba6c831 21986a1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
"use client";
import "./Card.css";
import { FaCompactDisc } from "react-icons/fa"; // Importing the add icon
import { TbPlaylistAdd } from "react-icons/tb";
import { useMusicPlayer } from "@/context/MusicPlayerContext";
import { formatTitle } from "@/lib/utils";
const Card = ({ src }) => {
const { initializePlayer, nowPlaying, addToPlayqueue } = useMusicPlayer();
const title = formatTitle(src);
const handlePlayButtonClick = () => {
initializePlayer(src, title);
};
const handleAddToPlayqueueClick = (e) => {
e.stopPropagation(); // Prevent the button click from triggering the card play
addToPlayqueue({ source: src, title });
console.log(`${title} added to play queue`)
};
return (
<>
<button onClick={handlePlayButtonClick}>
<div className={`music-card ${nowPlaying === title ? "now-playing" : ""}`}>
<FaCompactDisc className="card-icon" />
<label className="card-title">{title}</label>
</div>
</button>
<button className="add-to-playlist" onClick={handleAddToPlayqueueClick}>
<TbPlaylistAdd className="add-icon" />
</button>
</>
);
};
export default Card;
|