tramhao / termusic

Music Player TUI written in Rust
GNU General Public License v3.0
1.03k stars 44 forks source link

Metadata change delay #363

Open ShrekRequiem opened 4 weeks ago

ShrekRequiem commented 4 weeks ago

Environment & Versions

Logs: empty

Description of the Problem

It's working perfectly but there is a big delay between a song change and the time playerctl metadata change. It's not a big deal but I have the following script that I use to have a little player on my waybar and it doesn't change until minutes after the song change. The problem is specific to termusic (no problem with other players) and stays regardless of the backend (tried all of them). I might've missed something but I'm pretty sure this is my last resort.

#!/bin/bash

playerctl_status=$(playerctl status 2>/dev/null)

if [[ $playerctl_status == "Playing" ]]; then
    title=$(playerctl metadata title 2>/dev/null)
    echo '{"text":"󰎈 󰏤","class":"playing","title":"$title"}'
elif [[ $playerctl_status == "Paused" ]]; then
    title=$(playerctl metadata title 2>/dev/null)
    echo '{"text":"󰎈 󰐊","class":"paused","title":"$title"}'
else
    echo '{"text":""}'
fi
tramhao commented 4 weeks ago

I also met such delay before. To solve it, I even added a TICK to update mpris after each action. But it's not working...

ShrekRequiem commented 4 weeks ago

I also met such delay before. To solve it, I even added a TICK to update mpris after each action. But it's not working...

Glad to know I'm not the only one, did you manage to solve it in the end or just switch music player ? I really like termusic

tramhao commented 4 weeks ago

I am trying to fix it. Currently the structure is a little complex. The mpris is managed by server, and there are several delay in the whole process.

tramhao commented 3 weeks ago

I think e03018738c816ba0fa11adfc3744310229dd3476 fixed this problem. Please try to checkout the source in master and see if it's ok.

tramhao commented 3 weeks ago

By the way, I'm also using waybar, but with a little different solution. I'm using a script from:

https://github.com/polybar/polybar-scripts/blob/master/polybar-scripts/player-mpris-tail/player-mpris-tail.py

And my configuration in waybar is:

    "custom/mpris": {
        "format": "{}",
        // "return-type": "json",
        // "format-icons": {
        //     "Playing": " ",
        //     "Paused": " ",
        // },
        "max-length":30,
        "exec": "~/.config/waybar/scripts/player-mpris-tail.py -f '{icon} {artist} - {title}' -b plasma-browser-integration -b chromium",
        "on-click": "~/.config/waybar/scripts/player-mpris-tail.py play-pause",
        "on-click-right": "~/.config/waybar/scripts/player-mpris-tail.py next",
        "on-click-middle": "~/.config/waybar/scripts/player-mpris-tail.py previous",
    },