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 7 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.

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