Files
bar/include/services/dbus/mpris.hpp

35 lines
889 B
C++

#pragma once
#include <giomm.h>
#include <string>
#include <vector>
class MprisController {
public:
struct MprisPlayer2Message {
std::string title;
std::string artist;
std::string artwork_url;
std::function<void()> play_pause;
std::function<void()> next;
std::function<void()> previous;
};
MprisController();
void toggle_play();
void next_song();
void previous_song();
private:
Glib::RefPtr<Gio::DBus::Connection> m_connection;
Glib::RefPtr<Gio::DBus::Proxy> m_proxy;
void on_bus_connected(const Glib::RefPtr<Gio::AsyncResult> &result);
void launchNotification();
// Called when the song changes
void on_properties_changed(const Gio::DBus::Proxy::MapChangedProperties &changed_properties,
const std::vector<Glib::ustring> &invalidated_properties);
};