#78 Music Player optimization

Closed
opened 5 years ago by Farmerjoe12 · 5 comments

The music player uses a global dictionary, and has a variety of issues associated with that.

A music player should be able to:

  • Keep track of the current song playing
  • Get the previous song played
  • Get the next song to play
  • Pause/Continue

The global dictionary does not support this.

A better collection should be used. A linked list would be very good for this situation. Other collections like a hashmap would work too.

There needs to be some way to track the state of the currently playing song. This would allow messages to be sent when the song ends so that the next song can play. A problem that could arise here is an infinite loop constantly checking the status of the song and blocking the game from playing.

The music player uses a global dictionary, and has a variety of issues associated with that. A music player should be able to: - Keep track of the current song playing - Get the previous song played - Get the next song to play - Pause/Continue The global dictionary does not support this. A better collection should be used. A linked list would be very good for this situation. Other collections like a hashmap would work too. There needs to be some way to track the state of the currently playing song. This would allow messages to be sent when the song ends so that the next song can play. A problem that could arise here is an infinite loop constantly checking the status of the song and blocking the game from playing.
shuvit commented 5 years ago
Owner

I agree with all of that. The current issue is I don’t know of a way of checking the song position without using a different library. So that is step 1 I think.

Only the state and controls need to be in the global dict, the playlist and previous/next tracks can be moved locally.

I agree with all of that. The current issue is I don't know of a way of checking the song position without using a different library. So that is step 1 I think. Only the state and controls need to be in the global dict, the playlist and previous/next tracks can be moved locally.
Farmerjoe12 commented 5 years ago
Collaborator

Why does anything need to be in the global dict? If the music player class is the only one who knows about the music player, then why bother with the global vars?

Why does anything need to be in the global dict? If the music player class is the only one who knows about the music player, then why bother with the global vars?
shuvit commented 5 years ago
Owner

Almost everything gets the input status from global dict. I guess the only thing the music player needs to send out is the song name and the player status (playing/not). This is read from global dict on the overlay scene. If there’s a better way to pass the info I’m all for it, but this seems simplest and cleanest. :shrug:

I think you are thinking more about just abstracting the controls and status out of the player? That’s fine. For example we could just send requests to the component for play/pause and have it return track info.

Almost everything gets the input status from global dict. I guess the only thing the music player needs to send out is the song name and the player status (playing/not). This is read from global dict on the overlay scene. If there's a better way to pass the info I'm all for it, but this seems simplest and cleanest. :shrug: I think you are thinking more about just abstracting the controls and status out of the player? That's fine. For example we could just send requests to the component for play/pause and have it return track info.
Farmerjoe12 commented 5 years ago
Collaborator

This issue is being handled by the Music Player branch. When the branch merges, this issue can be closed.

This issue is being handled by the Music Player branch. When the branch merges, this issue can be closed.
shuvit commented 5 years ago
Owner

branch has been merged. considering this done for now.

branch has been merged. considering this done for now.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
Cancel
Save
There is no content yet.