[GH-ISSUE #712] Mpris playback status spammed #1358

Open
opened 2026-03-14 14:31:39 +03:00 by kerem · 1 comment
Owner

Originally created by @JohnOberhauser on GitHub (May 6, 2025).
Original GitHub issue: https://github.com/aome510/spotify-player/issues/712

Describe the bug
When watching for mpris signals, I can see the playback status getting sent once per second.

Also, I find that mpris signals are about 1-2 seconds delayed. E.g. after switching tracks, I don't see track updates for about 1-2 seconds. In the official app, I see them immediately.

To Reproduce
Run this python script to watch for mpris signals. Then run spotify-player and observer the mpris signals

#!/usr/bin/env python3
import dbus
import dbus.mainloop.glib
from gi.repository import GLib
import pprint

def convert_dbus(value):
    """
    Recursively convert dbus types to native Python types.
    """
    if isinstance(value, dbus.Dictionary):
        # Convert the dictionary and its keys/values
        return {convert_dbus(key): convert_dbus(val) for key, val in value.items()}
    elif isinstance(value, dbus.Array):
        # Convert each element in the array
        return [convert_dbus(item) for item in value]
    elif isinstance(value, dbus.ObjectPath):
        # Convert ObjectPaths to string
        return str(value)
    else:
        # For most other dbus types (e.g., dbus.String, dbus.Int64), they already behave like Python types.
        return value

def signal_handler(interface, changed_properties, invalidated_properties, path=None, sender=None):
    print("Received a PropertiesChanged signal:")
    print("Sender:", sender)
    print("Object Path:", path)
    print("Interface:", interface)
    
    # Convert dbus types to native Python types
    converted_properties = convert_dbus(changed_properties)
    converted_invalidated = convert_dbus(invalidated_properties)
    
    # Pretty print the dictionaries
    print("Changed Properties:")
    pp = pprint.PrettyPrinter(indent=4)
    pp.pprint(converted_properties)
    
    print("Invalidated Properties:")
    pp.pprint(converted_invalidated)
    print("-" * 50)

# Set up the main loop for D-Bus events
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()

# Subscribe to the PropertiesChanged signal from the MPRIS interface
bus.add_signal_receiver(
    signal_handler,
    signal_name="PropertiesChanged",
    dbus_interface="org.freedesktop.DBus.Properties",
    path="/org/mpris/MediaPlayer2",
    sender_keyword='sender',
    path_keyword='path'
)

print("Listening for MPRIS signals... (press Ctrl+C to exit)")
loop = GLib.MainLoop()
loop.run()

Expected behaviour
Playback status should not be spammed once per second. The signal should only be sent when playback status has changed.

Environment

  • OS: Arch linux
  • Application version: spotify_player 0.20.4
  • Application features: --features notify,pulseaudio-backend,media-control,daemon,fzf
Originally created by @JohnOberhauser on GitHub (May 6, 2025). Original GitHub issue: https://github.com/aome510/spotify-player/issues/712 **Describe the bug** When watching for mpris signals, I can see the playback status getting sent once per second. Also, I find that mpris signals are about 1-2 seconds delayed. E.g. after switching tracks, I don't see track updates for about 1-2 seconds. In the official app, I see them immediately. **To Reproduce** Run this python script to watch for mpris signals. Then run spotify-player and observer the mpris signals ``` #!/usr/bin/env python3 import dbus import dbus.mainloop.glib from gi.repository import GLib import pprint def convert_dbus(value): """ Recursively convert dbus types to native Python types. """ if isinstance(value, dbus.Dictionary): # Convert the dictionary and its keys/values return {convert_dbus(key): convert_dbus(val) for key, val in value.items()} elif isinstance(value, dbus.Array): # Convert each element in the array return [convert_dbus(item) for item in value] elif isinstance(value, dbus.ObjectPath): # Convert ObjectPaths to string return str(value) else: # For most other dbus types (e.g., dbus.String, dbus.Int64), they already behave like Python types. return value def signal_handler(interface, changed_properties, invalidated_properties, path=None, sender=None): print("Received a PropertiesChanged signal:") print("Sender:", sender) print("Object Path:", path) print("Interface:", interface) # Convert dbus types to native Python types converted_properties = convert_dbus(changed_properties) converted_invalidated = convert_dbus(invalidated_properties) # Pretty print the dictionaries print("Changed Properties:") pp = pprint.PrettyPrinter(indent=4) pp.pprint(converted_properties) print("Invalidated Properties:") pp.pprint(converted_invalidated) print("-" * 50) # Set up the main loop for D-Bus events dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() # Subscribe to the PropertiesChanged signal from the MPRIS interface bus.add_signal_receiver( signal_handler, signal_name="PropertiesChanged", dbus_interface="org.freedesktop.DBus.Properties", path="/org/mpris/MediaPlayer2", sender_keyword='sender', path_keyword='path' ) print("Listening for MPRIS signals... (press Ctrl+C to exit)") loop = GLib.MainLoop() loop.run() ``` **Expected behaviour** Playback status should not be spammed once per second. The signal should only be sent when playback status has changed. **Environment** - OS: Arch linux - Application version: spotify_player 0.20.4 - Application features: --features notify,pulseaudio-backend,media-control,daemon,fzf
Author
Owner

@itsvyle commented on GitHub (May 31, 2025):

I'm having the same issue, with very delayed updates; any progress on this?

<!-- gh-comment-id:2925372797 --> @itsvyle commented on GitHub (May 31, 2025): I'm having the same issue, with very delayed updates; any progress on this?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#1358
No description provided.