Skip to main content

DBus MediaPlayer

PyPI Python versions License

The dbus-mediaplayer library empowers Python applications to interact with media players on your system through the D-Bus communication protocol. This enables you to retrieve metadata (like song titles and artists), control playback (play, pause, next, etc.), and potentially even access features specific to certain media players.

Key Features

  • Media Player Discovery: Enumerate available media players on your system.
  • Metadata Access: Retrieve current song information (title, artist, album, etc.).
  • Playback Control: Play, Pause, Skip tracks, Volume, Position.
  • Real-time Updates: Utilizes callback functions to provide instant notifications of media player state changes, ensuring your application stays up-to-date.

Requirements

  • Python 3.7 or later
  • jeepney library

Installation

Install the library using pip:

pip install dbus-mediaplayer

Usage

This library offers two primary usage approaches:

Programmatic Control

Import the DBusMediaPlayers class from your Python code:

from dbus_mediaplayer import DBusMediaPlayers

def callback(players):
    # Handle the list of media player objects here
    print(players)

# Create an instance of the class
media_player = DBusMediaPlayers(callback)

# Control media playback (replace "PlayPause" with desired methods like "Play", "Pause", "Next", etc.)
media_player.control_media("PlayPause")

# Keep the app running
while True:
    time.sleep(1)

Command-Line Interaction (Optional)

If you prefer a quick way to view information or control playback, you can potentially execute the dbus-mediaplayer script directly. For more extensive programmatic control, I would recommend using the library within your Python code. The script supports the following optional arguments for media control:

Status (Default):

If no argument is provided, the script defaults to retrieving media player information.

dbus-mediaplayer get-info

Volume Control:

You can set the volume level (between 0.0 and 1.0).

dbus-mediaplayer control --volume 0.5   # Sets volume to 50%

Set Media Position:

Adjust the playback position in seconds.

dbus-mediaplayer control --position 120  # Sets position to 2 minutes

Playback Control:

Perform media control actions: Play, Pause, PlayPause, Stop, Next, Previous.

dbus-mediaplayer command Pause  # Pauses playback
dbus-mediaplayer command Play   # Plays playback

This flexible command-line approach offers a straightforward way to control media playback directly from the terminal.

Inspiration

This library was inspired by the MPRIS2 library, which utilizes the dbus-python library. However, dbus-mediaplayer aims to offer a more widely deployable solution, removing reliance on external dependencies.

Metadata

Release files for dbus-mediaplayer 2026.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbus-mediaplayer 2026.7.0
File Size Uploaded Provenance Actions
dbus_mediaplayer-2026.7.0.tar.gz 5.7 kB Without provenance Details for dbus_mediaplayer-2026.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dbus-mediaplayer 2026.7.0
File Interpreter ABI Platform Actions
dbus_mediaplayer-2026.7.0-py3-none-any.whl Python 3 none any Details for dbus_mediaplayer-2026.7.0-py3-none-any.whl

Total release size: 12.2 kB

Release files / dbus_mediaplayer-2026.7.0.tar.gz

Download URL dbus_mediaplayer-2026.7.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2caaff0dd9dc7977e64bb574dc7a223845ac851745265b680deb586a9df564e5
BLAKE2b-256 checksum
How to use checksums
249f43e91c388e52dd482ce28e30faa96c94befba617dd19f738907d7cf8b4e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / dbus_mediaplayer-2026.7.0-py3-none-any.whl

Download URL dbus_mediaplayer-2026.7.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ed5cd9212868cdf21485ba9992689ee084b5310126933295de542160fd128a4
BLAKE2b-256 checksum
How to use checksums
4fbb27ac5925d8eda4a355d1f111663d0f237595310333962f251d168b3f89f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for dbus-mediaplayer 2026.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page