Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix song playback #6

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Fix song playback #6

wants to merge 18 commits into from

Conversation

seungguini
Copy link
Owner

@seungguini seungguini commented Nov 15, 2022

Several functionalities fixed regarding audio playback / skipping between songs

  • Fix sound on/ sound off button
  • Add utility file utils.js, which currently stores the meta data for lofi songs
  • Fix Previous Music / Next Music functionality for the lofi songs
  • Add song title / artist name dynamically (animated appear/disappear) based on playing status
  • Refactor code into Song.js, Lights.js, and Turntable.js - overall lightening the load on App.js
    @320834 Feel free to check out the branch on your local, but I won't merge until we talk about it this weekend.

@seungguini
Copy link
Owner Author

Additional features (starting from commit 6057f5e):

  • Album picture dynamically changes per song.
  • Album picture turns / stops turning based on play status

NOTE: Request new turntable.glb model file

Copy link
Collaborator

@320834 320834 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial comments. Looking more into Song.js a little more in depth in the next few days.

frontend/src/App.js Outdated Show resolved Hide resolved
frontend/src/App.js Outdated Show resolved Hide resolved
@@ -32,110 +35,21 @@ const Scene = () => {
const [playing, setPlaying] = useState(false);
const [soundOn, setSoundOn] = useState(true);
const [toneArmFinished, setToneArmFinished] = useState(false);
const coverPicUrls = ["Aiguille.jpg", "CanaryForest.jpg", "Sworn.jpg"];
const [coverPicUrl, setCoverPicUrl] = useState("Aiguille.jpg");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do something like this?

const [coverPicUrl, setCoverPicUrl] = useState(coverPicUrls[songIndex])

Also maybe move the songIndex state above this line.

frontend/src/components/Button.js Show resolved Hide resolved
frontend/src/components/Buttons.js Outdated Show resolved Hide resolved
const y = 1.4;
const z = 4;

const [songs, setSongs] = useState(data()); // List of songs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are not going to use setSongs, then we probably don't need a state. Let me know if it works if you just declare a const and not have it be a state for the component.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@320834 You're right that we won't need it for now, but I think we might need something similar when we tie in the Spotify API.

IE : If the user builds a queue of songs to listen, then setSongs would be needed to update the list of songs (which would be displayed in the frontend).

Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah understood, but we will add it in when we get to that point.

Comment on lines 25 to 34
const [currentSong, setCurrentSong] = useState({
name: "Beaver Creek",
cover:
"https://chillhop.com/wp-content/uploads/2020/09/0255e8b8c74c90d4a27c594b3452b2daafae608d-1024x1024.jpg",
artist: "Aso, Middle School, Aviino",
audio: "Beaver Creek.mp3",
color: ["#205950", "#2ab3bf"],
id: uuidv4(),
active: true,
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to set it to the first element of the data?

Comment on lines 54 to 56
useEffect(() => {
setCurrentSong(songs[0]);
}, [songs]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this will ever get run. Basically if songs is ever changed, then it will run this effect, but I don't see anything that changes the song state.

https://reactjs.org/docs/hooks-effect.html#tip-optimizing-performance-by-skipping-effects

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the intention of this is to run it upon first render and it does the intended task then disregard this message

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was indeed intended to run on the first render, especially because the songs list is initialized from a separate function. Sometimes the currentSong is loaded before the songs is loaded in, which crashes the app.

However, I do think the useEffect will need to change - songs is intended to be the Spotify queue of songs for the user. We don't want to set the current song to the first song every time a new song is added to songs (which will happen in the current code).

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote let's keep the songs / setSongs parts as is for now, we'll leave it as imperfect code snippets that exist as to-do's once the API is working.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, just keep a mental note to revisit this later.

frontend/src/utils.js Outdated Show resolved Hide resolved
frontend/src/components/Turntable.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@320834 320834 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just address some of the other comments and I think it's good to go.

frontend/src/components/Song.js Outdated Show resolved Hide resolved
Comment on lines 67 to 69
useEffect(() => {
document.body.style.cursor = hovering ? "pointer" : "auto"; // change pointer to finger when hovered
// document.body.style.cursor = hovering ? "pointer" : "auto"; // change pointer to finger when hovered
}, [hovering]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not used, then maybe get rid of this useEffect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants