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/screens/StationPage.jsx b/frontend/src/screens/StationPage.jsx
index b3e5062..50df4e3 100644
--- a/frontend/src/screens/StationPage.jsx
+++ b/frontend/src/screens/StationPage.jsx
@@ -1,6 +1,8 @@
import { useParams } from "react-router-dom";
import React, { useState, useEffect } from "react";
import { addClientToStation } from "../utils/AddClientToStation";
+import { getAudioFiles } from "../utils/AudioFiles";
+import SingleAudioPlayer from "../components/AudioPlayer";
function StationPage() {
const { stationID } = useParams();
@@ -31,7 +33,7 @@ function StationPage() {
);
}
- const recommendedSongs = [];
+ const recommendedSongs = getAudioFiles() ?? [];
return (
@@ -46,6 +48,7 @@ function StationPage() {
Serena Station
Collaborative Music Experience
+
@@ -58,15 +61,7 @@ function StationPage() {
No songs in queue yet. Add some songs to get started!
) : (
- recommendedSongs.map((song) => (
-
-
-
{song.title}
-
{song.artist}
-
-
{song.duration}
-
- ))
+ recommendedSongs.map((song) =>
{song}
)
)}
diff --git a/frontend/src/utils/AudioFiles.js b/frontend/src/utils/AudioFiles.js
new file mode 100644
index 0000000..36568f4
--- /dev/null
+++ b/frontend/src/utils/AudioFiles.js
@@ -0,0 +1,5 @@
+const importAll = (r) => r.keys().map(r);
+
+export const getAudioFiles = () => {
+ return importAll(require.context("../../music", false, /\.(mp3|wav)$/));
+};