diff --git a/frontend/.gitignore b/frontend/.gitignore index 4d29575..fe844a4 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -21,3 +21,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +music/* \ No newline at end of file diff --git a/frontend/src/components/AudioPlayer.jsx b/frontend/src/components/AudioPlayer.jsx new file mode 100644 index 0000000..e8fea80 --- /dev/null +++ b/frontend/src/components/AudioPlayer.jsx @@ -0,0 +1,35 @@ +import React, { useRef, useState } from "react"; + +const SingleAudioPlayer = ({ src }) => { + const audioRef = useRef(null); + const [isPlaying, setIsPlaying] = useState(false); + + const togglePlay = () => { + const audio = audioRef.current; + if (!audio) return; + + if (isPlaying) { + audio.pause(); + } else { + audio.play().catch((e) => { + console.warn("Playback error:", e); + }); + } + + setIsPlaying(!isPlaying); + }; + + const handleEnded = () => { + setIsPlaying(false); + }; + + return ( +
+ + {src.split("/").pop()} +
+ ); +}; + +export default SingleAudioPlayer; diff --git a/frontend/src/components/LoginButton.jsx b/frontend/src/components/LoginButton.jsx deleted file mode 100644 index f928e40..0000000 --- a/frontend/src/components/LoginButton.jsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import { getSpotifyLoginUrl, isLoggedIn, removeAccessToken } from '../utils/spotifyAuth.js'; - -const LoginButton = () => { - const loggedIn = isLoggedIn(); - - const handleLogout = () => { - removeAccessToken(); - window.location.reload(); // Refresh to update UI - }; - - if (loggedIn) { - return ( -
- ✓ Connected to Spotify - -
- ); - } - - return ( - - - - ); -}; - -export default LoginButton; diff --git a/frontend/src/constants/ApiConstants.js b/frontend/src/constants/ApiConstants.js index caaf274..7cdec44 100644 --- a/frontend/src/constants/ApiConstants.js +++ b/frontend/src/constants/ApiConstants.js @@ -3,6 +3,3 @@ export const RADIOSTATION_URL = "http://localhost:8080/api"; export const CREATE_RADIOSTATION_ENDPOINT = "/radio-stations"; export const LIST_RADIOSTATIONS_ENDPOINT = "/radio-stations"; export const ADD_CLIENT_ENDPOINT = "/clients/connect"; - -export const SPOTIFY_PREMIUM_TOKEN = - "BQCEnWrYVdmta4Eekdkewazun99IuocRAyPEbwPSrHuGYgZYg7JGlXG2BLmRL6fwjzPJkrmHiqlTLSn1yqR36awA9Rv4n9dwvTBv1DjAitsuzaEVg7PtYdbUHXqP2HJJ4dDDvTtvUfWIBDY_Afa7WgY1cyRbl-p4VobNHXUR9N3Ye1qBTgH3RZ5ziIbIoNWe_JrxYvcedkvr23zXUVabOyahTgt_YdmnCWt2Iu8XT8sjhSyc8tOCqbs_KqE-Qe1WSPUCrGS8"; diff --git a/frontend/src/screens/StationPage.jsx b/frontend/src/screens/StationPage.jsx index 35ea7e9..50df4e3 100644 --- a/frontend/src/screens/StationPage.jsx +++ b/frontend/src/screens/StationPage.jsx @@ -1,13 +1,12 @@ import { useParams } from "react-router-dom"; import React, { useState, useEffect } from "react"; -import AddSongModal from "./AddSongModal"; -import LoginButton from "../components/LoginButton"; import { addClientToStation } from "../utils/AddClientToStation"; +import { getAudioFiles } from "../utils/AudioFiles"; +import SingleAudioPlayer from "../components/AudioPlayer"; function StationPage() { const { stationID } = useParams(); const [clientToken, setClientToken] = useState(""); - const [isModalOpen, setIsModalOpen] = useState(false); const [accessDenied, setAccessDenied] = useState(true); const [userName, setUserName] = useState(""); @@ -29,20 +28,12 @@ function StationPage() {