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

Music Player Progress Bar Not Updating Correctly When Paused with Spotify And Local Media Players #107

Open
ahmedreda1009 opened this issue Aug 18, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ahmedreda1009
Copy link

ahmedreda1009 commented Aug 18, 2024

The issue:
The music player widget in the Tokyo Night Tmux theme's status bar continues to update the progress bar and time even when the music is paused. This results in incorrect display of the music progress when the player is not actively playing music.

Steps to reproduce the issue:

  1. Open Tmux with the Tokyo Night Tmux theme applied.
  2. Start a music player
  3. Observe the progress bar and time display in the Tmux status bar.
  4. Pause the music player.
  5. Notice that the progress bar and time continue to update as if the music is still playing.

Screenshots:
Screenshot 2024-08-18 at 1 17 41 PM

Environment:

  • OS: macOS 14.6.1
  • Terminal: Kitty
  • Tmux version: 3.4
  • Tokyo Night Tmux branch: master

Notes:

  • My music player is Spotify.
  • This issue doesn't happen with YouTube and it happens with Spotify and local media player like IINA.
@ahmedreda1009 ahmedreda1009 changed the title Music Player Progress Bar Not Updating Correctly When Paused with Spotify Music Player Progress Bar Not Updating Correctly When Paused with Spotify And Local Media Players Aug 18, 2024
@janoamaral janoamaral added the bug Something isn't working label Aug 21, 2024
@janoamaral janoamaral self-assigned this Nov 11, 2024
@Xavier-PDL
Copy link

Xavier-PDL commented Jan 7, 2025

Looks like this issue goes as deep as coming from the MediaRemote library nowplaying-cli is using to retrieve this information.

There's also an issue on the nowplaying-cli issue tracker that mirrors this issue: kirtan-shah/nowplaying-cli#15

Code is pretty straight-forward though, they're just getting the data and spitting it out. So unless apple decides to change this behavior, I think we're stuck fixing this somewhere downstream. I took the obvious approach and just use a temp file to "fix" it.

index 6f25b4e..44ad6c1 100755
--- a/src/music-tmux-statusbar.sh
+++ b/src/music-tmux-statusbar.sh
@@ -72,6 +72,12 @@ elif command -v nowplaying-cli >/dev/null; then
   else
     DURATION=$(printf "%.0f" "${NPCLI_VALUES[duration]}")
     POSITION=$(printf "%.0f" "${NPCLI_VALUES[elapsedTime]}")
+    if [ "$STATUS" = "playing" ]; then
+      echo "$POSITION" >/tmp/last_position
+    fi
+    if [ "$STATUS" = "paused" ]; then
+      POSITION=$(cat /tmp/last_position)
+    fi
   fi
 fi

@janoamaral
Copy link
Owner

janoamaral commented Jan 12, 2025

Hi, I added this fix to the next branch. Please feel free to check as if it works as it should. If everything works, it should be shipped in the next release.

@Xavier-PDL
Copy link

Yep, looks good to me 👍

@janoamaral
Copy link
Owner

Yep, looks good to me 👍

Thanks for the feedback!

@ionztorm
Copy link

Possibly related, but can add a new issue if needed.

on macOS, with Apple Music, when playing a playlist, the music player stops tracking progress and time when the song auto switches to the next song in the playlist.

Image

I did run this script in my term outside of tmux to check if this was a issue with Nowplaying CLI:

while true; do
  echo "Title: $(nowplaying-cli get title 2>/dev/null)"
  echo "Duration: $(nowplaying-cli get duration 2>/dev/null)"
  echo "Elapsed Time: $(nowplaying-cli get elapsedTime 2>/dev/null)"
  sleep 1
done

and the output was:

Title: Crimsom
Duration: 382.556
Elapsed Time: 378.964106
Title: Crimsom
Duration: 382.556
Elapsed Time: 380.217805
Title: Crimsom
Duration: 382.556
Elapsed Time: 381.435294
Title: Strangers
Duration: null
Elapsed Time: null
Title: Strangers
Duration: 173.008
Elapsed Time: 0.503326
Title: Strangers
Duration: 173.008
Elapsed Time: 1.831192

So it's not a limitation of nowplaying cli it would seem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants