Currently playng media using DBus
Project description
DBus MediaPlayer
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
jeepneylibrary
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbus_mediaplayer-2025.6.0.tar.gz.
File metadata
- Download URL: dbus_mediaplayer-2025.6.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6a101c0499ed53ea7b4d503789d47101c2fa941da140ce1430a3bd9e80aefc4
|
|
| MD5 |
e49b0aa63e3a5edd40a471bfd1432702
|
|
| BLAKE2b-256 |
05cd8041153ed096c3ae8f15242cb6884a55b4ab875959da60d1b4c9e8e940e4
|
File details
Details for the file dbus_mediaplayer-2025.6.0-py3-none-any.whl.
File metadata
- Download URL: dbus_mediaplayer-2025.6.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
142e427b019672fbd40cb26db019784da8684594d2670c2e6366154276d18611
|
|
| MD5 |
85c7b3100c04060a264d5b4362be5dda
|
|
| BLAKE2b-256 |
3bd10a275995f9fdd807531b143e6020e1e18de9a8e7202a6674ba6160ccc6e4
|