https://github.com/hbacelar8/mprisctl
C++ MPRIS controller library
https://github.com/hbacelar8/mprisctl
cpp dbus mpris
Last synced: 9 months ago
JSON representation
C++ MPRIS controller library
- Host: GitHub
- URL: https://github.com/hbacelar8/mprisctl
- Owner: hbacelar8
- Created: 2025-02-09T22:00:29.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-02-11T21:21:36.000Z (11 months ago)
- Last Synced: 2025-02-11T21:34:12.415Z (11 months ago)
- Topics: cpp, dbus, mpris
- Language: C++
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MPRIS Controller Library
C++ MPRIS controller library implementation, inspired on the functionnalities of
the [playerctl](https://github.com/altdesktop/playerctl) project.
This is a library though, not intented to be used as a CLI tool.
## Configure and build
In the project's root:
```bash
cmake --preset example
```
```bash
cmake --build build
```
## Run the example
```bash
./build/examples/example
```
## Example usage
```cpp
#include
#include "mprisctl.h"
int main()
{
// Instantiate the MPRIS controller, opening the ubs connection
mpris_ctl::MPRISController mpris_controller;
// Get a list of all players
auto players = mpris_controller.GetAvailablePlayers();
// Print all players
std::cout << "List of all players:" << std::endl;
for (auto player : players)
{
std::cout << "- " << player << std::endl;
}
// Get first player
std::string player = players[0];
// Toogle play/pause
mpris_controller.PlayPause(player);
// Get metadata and print it
std::cout << "\nMetadata:" << std::endl;
mpris_ctl::TrackMetadata metatada = mpris_controller.GetMetadata(player);
std::cout << "Title: " << metatada.title << std::endl;
std::cout << "Artist: " << metatada.artist << std::endl;
std::cout << "Album: " << metatada.album << std::endl;
std::cout << "Art URL: " << metatada.artUrl << std::endl;
std::cout << "URL: " << metatada.url << std::endl;
std::cout << "Length: " << metatada.length << std::endl;
// Toggle play/pause
mpris_controller.PlayPause(player);
return 0;
}
```