Skip to main content

Currently playng media using DBus

Project description

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.
  • 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:

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

dbus_mediaplayer-2025.3.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbus_mediaplayer-2025.3.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file dbus_mediaplayer-2025.3.0.tar.gz.

File metadata

  • Download URL: dbus_mediaplayer-2025.3.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for dbus_mediaplayer-2025.3.0.tar.gz
Algorithm Hash digest
SHA256 95c9ec12fa5e0038bc94e64becb867ff47f097bd124d67e997220f39fcf3a144
MD5 6e3a35635dddba245fe0b61e01185d61
BLAKE2b-256 d46093778dcce554b8234e7dc5f47c9a58884c97ba87ddfc7ffa8e1c41e03f9d

See more details on using hashes here.

File details

Details for the file dbus_mediaplayer-2025.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dbus_mediaplayer-2025.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ae95d81b6598a7357decda92b4afa59b98e879d47edb5063393236ba5a3a1b1
MD5 8be023c39b5c6f73ad58092ed1dafa5e
BLAKE2b-256 13edb2cdb347d1884422821c274711310e30a5b52ded378b45a57b123772c787

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page