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

MOBILE-212: Highlight current playing song & dynamic PlayButton #518

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Shreyassp002
Copy link
Contributor

@Shreyassp002 Shreyassp002 commented Dec 28, 2024

This PR focuses on highlighting the title of the currently playing song and changing the icon in BrainzPlayerListenCard.

Changes:

  • Added a visual highlight to the title of the song currently playing in the list.
  • Added logic to match the currentlyPlayingTitle with the title passed to the BrainzPlayerListenCard composable. If they match, the title color will be changed; otherwise, it uses the default text color from the theme.
  • Added animated Play/Pause Icon transition in BrainzPlayerListenCard
  • Also made some formatting fixes for better code readability.

Screenshots:

Screenshot 1 Screenshot 2

Issue Link: MOBILE-212

This is the current implementation of feature. I’d love to hear your feedback or suggestions for improvement.

@Shreyassp002
Copy link
Contributor Author

Shreyassp002 commented Dec 29, 2024

Changed highlight color
Once the color is confirmed, I will add to Color.kt (Temporarily hardcoded)

Screenshots:

Screenshot 1 Screenshot 2

Let me know if any changes are required.

@Shreyassp002
Copy link
Contributor Author

Added animated Play/Pause Icon transition in BrainzPlayerListenCard

  • Updated the PlayButton composable to use AnimatedContent for animating the icon transition.
  • Added fade-in and fade-out effects to the play/pause icon transition.
  • Ensured the play/pause icon synchronizes correctly with the song's playing state.

Screenshot:

Screenshot of the app

@Shreyassp002 Shreyassp002 changed the title MOBILE-212: Highlight current playing song in song list MOBILE-212: Highlight current playing song & dynamic PlayButton Jan 1, 2025

init {
updatePlayerPosition()
viewModelScope.launch(Dispatchers.IO) {
brainzPlayerServiceConnection.currentPlayingSong.collectLatest { song ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need to collect the flow and emit to another flow.

val currentlyPlayingTitle = brainzPlayerServiceConnection.currentPlayingSong.map { it.title }

Also, rather than just flowing the title here, can we do brainzPlayerServiceConnection.currentPlayingSong only and use title wherever needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that’s better.
Removing the redundant flow.

@@ -172,6 +179,7 @@ class BrainzPlayerViewModel @Inject constructor(
viewModelScope.launch { songRepository.updateSong(mediaItem) }
brainzPlayerServiceConnection.transportControls.playFromMediaId(mediaItem.mediaID.toString(), null)
}
_currentlyPlayingTitle.value = mediaItem.title
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need to emit here, service connection should automatically update the above flow. If not, it would be a bug for BP Service connection that would need to be resolved.

) {
val isPlaying by viewModel.isPlaying.collectAsState()
val currentlyPlayingTitle by viewModel.currentlyPlayingTitle.collectAsState()
val titleColor = if (currentlyPlayingTitle == title) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tried using some ID of sorts like mediaID of a song? That would be a better candidate for this kind of use case.

Copy link
Contributor Author

@Shreyassp002 Shreyassp002 Jan 6, 2025

Choose a reason for hiding this comment

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

Yes, I tried to match the currentlyPlayingSong.id with the mediaId passed to the BrainzPlayerListenCard from SongsOverviewScreen, but that didn't work out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait I figured out a way to use mediaId instead of the Title

val isPlaying by viewModel.isPlaying.collectAsState()
val currentlyPlayingTitle by viewModel.currentlyPlayingTitle.collectAsState()
val titleColor = if (currentlyPlayingTitle == title) {
Color(0xFFB94FE5)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use ListenBrainzTheme.colorScheme.signatureInverse maybe or is it not legible enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I’m not wrong, lbSignatureInverse uses lb_orange, but Aerozol asked for a combination of blue and violet. Please suggest any combination or shade you’d like.

@07jasjeet
Copy link
Collaborator

07jasjeet commented Jan 11, 2025

Hey @Shreyassp002, I tried this on my device and the song is only highlighted on songs screen inside brainzplayer. Also, there seems to be much more improvements being tackled in this PR itself which are not polished and need more work. Implementing these features all over the app would be blow out the scope of this PR. Can we make this work just inside brainzplayer tab?

Here's the following that needs to done inside Brainzplayer tab:

  1. BP Dropdown on every screen in BP tab.
  2. Remove the dynamic play button and play the song on when the card is clicked itself.
  3. Highlight the listen card via shading the background with BrainzPlayerViewModel.playerBackgroundColor created by @GautamCoder4019k
  4. Highlight currently playing song on every screen in BP tab.

This feels like a huge task, we can split these into 3 PRs:
PR 1: Point 1
PR 2: Point 2
PR 3: Point 3 and 4

As for this PR, You can use this PR as a base branch for your other 3 PRs and we can close this one, or we you can complete any one of the task in this PR itself.

Edit: Drop dynamic play button and play the song on when the card is clicked.

@Shreyassp002
Copy link
Contributor Author

Hey @07jasjeet,
Thank you for the detailed feedback! I have a couple of questions before proceeding:

  1. Regarding point 1, "BP Dropdown on every screen in BP tab," could you clarify exactly what this means? Are you referring to the song selection dropdown or something else?

  2. Should I remove the play button completely from BrainzPlayerListenCard, or should it remain as it was before?

  3. I understand your concern about scope creep in this PR. I’ll split the tasks as suggested:

    • I can handle point 2 (removing the dynamic play button and playing the song when the BrainzPlayerListenCard is clicked) in this PR.
    • Then, I’ll create two more PRs for points 1, 3, and 4 accordingly.

@07jasjeet
Copy link
Collaborator

07jasjeet commented Jan 21, 2025

Hey @07jasjeet,
Thank you for the detailed feedback! I have a couple of questions before proceeding:

  1. Regarding point 1, "BP Dropdown on every screen in BP tab," could you clarify exactly what this means? Are you referring to the song selection dropdown or something else?

  2. Should I remove the play button completely from BrainzPlayerListenCard, or should it remain as it was before?

  3. I understand your concern about scope creep in this PR. I’ll split the tasks as suggested:

    • I can handle point 2 (removing the dynamic play button and playing the song when the BrainzPlayerListenCard is clicked) in this PR.
    • Then, I’ll create two more PRs for points 1, 3, and 4 accordingly.
  1. Currently, BP dropdown is not implemented on the albums tab and songs tab. For the songs tab, the implementation should be as recents tab, i.e., normal BP dropdown. As for albums, the page is messed up itself, and songs are displayed as albums. Let's remove the dropdown from every item in the tab.

  2. Remove the button from UI.

  3. Great.

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

Successfully merging this pull request may close these issues.

2 participants