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.
- 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
dasdbus
library
Installation
Install the library using pip:
pip install dbus-mediaplayer
Usage
This library offers two primary usage approaches:
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.
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)
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.
Future Features
While dbus-mediaplayer provides a solid foundation for interacting with media players, there's room for growth. Here are some features it is missing and could be implemented in future development:
- Seek Position Control: Allow users to set the playback position within a media track.
- Volume Control: Implement methods for adjusting media player volume. Note that volume control support may vary across different media players and platforms.
- Playback Capabilities: Provide methods to determine if a media player supports specific playback actions like next, previous, stop, and seek. This will allow users to tailor their interactions based on player capabilities.
Project details
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
Hashes for dbus_mediaplayer-2024.7.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f47eabc3b8bd2e52069076db49b0ed895d65cd2bd306cc35929e90dece5d4fd |
|
MD5 | db5a91032b53f4901762400e5feb611e |
|
BLAKE2b-256 | 352d14eb5ac44dfddf978ba6f14963c074865a5d4383ae4dd227d845a756ee86 |
Hashes for dbus_mediaplayer-2024.7.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e2164b2d301be0516929eff093136a5605b259edfa8e2234db0cac5dbf3386b |
|
MD5 | feaa805d0a6907ab85f48cdb36e0d107 |
|
BLAKE2b-256 | f5058d25b87a592702c9c07867af0896c25554ebfe4d830bd5949252c4eca94f |