26 #include <boost/asio.hpp>
40 : resume_key(
std::numeric_limits<
std::uint32_t>::max()),
41 keep_alive(io_service)
43 bus = std::shared_ptr<dbus::Bus>(
new dbus::Bus(core::dbus::WellKnownBus::session));
44 bus->install_executor(dbus::asio::make_executor(bus, io_service));
45 worker = std::move(std::thread([
this]()
52 auto stub_service = dbus::Service::use_service(bus,
"com.canonical.indicator.power");
53 indicator_power_session = stub_service->object_for_path(dbus::types::ObjectPath(
"/com/canonical/indicator/power/Battery"));
62 if (worker.joinable())
74 std::shared_ptr<core::dbus::Property<core::IndicatorPower::PowerLevel>>
power_level;
75 std::shared_ptr<core::dbus::Property<core::IndicatorPower::IsWarning>>
is_warning;
80 cout << __PRETTY_FUNCTION__ << endl;
86 if (level ==
"low" || level ==
"very_low")
87 pause_all_multimedia_sessions();
95 resume_multimedia_session();
104 const media::Player::Configuration& conf)
106 auto player = std::make_shared<media::PlayerImplementation>(
107 conf.identity, conf.bus, conf.session, shared_from_this(), conf.key);
110 player->on_client_disconnected().connect([
this, key]()
117 d->io_service.post([
this, key]()
130 cerr <<
"Could not find Player by key: " << key << endl;
152 cout <<
"Pausing Player with key: " << other_key << endl;
153 other_player->pause();
158 void media::ServiceImplementation::pause_all_multimedia_sessions()
166 cout <<
"Will resume playback of Player with key: " << d->resume_key << endl;
172 void media::ServiceImplementation::resume_multimedia_session()
181 cout <<
"Resuming playback of Player with key: " << d->resume_key << endl;
183 d->resume_key = std::numeric_limits<std::uint32_t>::max();