Merge lp:~phablet-team/media-hub/mpris into lp:media-hub/stable
- mpris
- Merge into stable
Proposed by
Jim Hodapp
Status: | Merged |
---|---|
Approved by: | Alfonso Sanchez-Beato |
Approved revision: | 172 |
Merged at revision: | 159 |
Proposed branch: | lp:~phablet-team/media-hub/mpris |
Merge into: | lp:media-hub/stable |
Diff against target: |
528 lines (+117/-120) 14 files modified
CMakeLists.txt (+1/-1) README (+9/-0) debian/changelog (+10/-0) include/core/media/service.h (+3/-0) src/core/media/mpris/service.h (+1/-0) src/core/media/player_implementation.cpp (+4/-2) src/core/media/service_implementation.cpp (+5/-0) src/core/media/service_implementation.h (+1/-0) src/core/media/service_skeleton.cpp (+72/-113) src/core/media/service_skeleton.h (+1/-0) src/core/media/service_stub.cpp (+9/-1) src/core/media/service_stub.h (+1/-0) src/core/media/track_list_implementation.cpp (+0/-2) src/core/media/track_list_skeleton.cpp (+0/-1) |
To merge this branch: | bzr merge lp:~phablet-team/media-hub/mpris |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alfonso Sanchez-Beato | Approve | ||
Review via email: mp+269755@code.launchpad.net |
Commit message
Re-enable MPRIS player controls and improves background playlists.
Description of the change
Re-enable MPRIS player controls and improves background playlists.
To post a comment you must log in.
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) : | # |
review:
Approve
lp:~phablet-team/media-hub/mpris
updated
- 173. By Jim Hodapp
-
Make sure the correct player is set as the current player controled by MPRIS. Also improved the can_go_next() and can_go_previous() logic to always return true if the loop_status is currently set to loop over the entire playlist.
- 174. By Jim Hodapp
-
Bump version for change in interface
- 175. By Jim Hodapp
-
Merged with upstream
- 176. By Jim Hodapp
-
Bumped the package version.
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
review:
Needs Fixing
lp:~phablet-team/media-hub/mpris
updated
- 177. By Jim Hodapp
-
Added link to a coding standard for this code base and fixed line length in debian/changelog entry.
Revision history for this message
Jim Hodapp (jhodapp) wrote : | # |
Comments addressed.
lp:~phablet-team/media-hub/mpris
updated
- 178. By Jim Hodapp
-
Address code review comments
- 179. By Jim Hodapp
-
Addressed review comment - check for if (sp) is now moved into is_multimedia_
role()
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2015-04-10 16:21:16 +0000 |
3 | +++ CMakeLists.txt 2015-09-09 16:32:06 +0000 |
4 | @@ -3,7 +3,7 @@ |
5 | project(ubuntu-media-hub) |
6 | |
7 | set(UBUNTU_MEDIA_HUB_VERSION_MAJOR 3) |
8 | -set(UBUNTU_MEDIA_HUB_VERSION_MINOR 1) |
9 | +set(UBUNTU_MEDIA_HUB_VERSION_MINOR 2) |
10 | set(UBUNTU_MEDIA_HUB_VERSION_PATCH 0) |
11 | |
12 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fPIC -pthread") |
13 | |
14 | === modified file 'README' |
15 | --- README 2014-08-08 14:36:29 +0000 |
16 | +++ README 2015-09-09 16:32:06 +0000 |
17 | @@ -1,3 +1,12 @@ |
18 | +Coding Convention: |
19 | +------------------ |
20 | + |
21 | +NOTE: the media-hub code did not start out with the following coding convention, but it is being introduced to try and |
22 | +converge on a standard from this point forward: |
23 | + |
24 | +https://google-styleguide.googlecode.com/svn/trunk/cppguide.html |
25 | + |
26 | + |
27 | To Build: |
28 | --------- |
29 | |
30 | |
31 | === modified file 'debian/changelog' |
32 | --- debian/changelog 2015-09-04 18:51:23 +0000 |
33 | +++ debian/changelog 2015-09-09 16:32:06 +0000 |
34 | @@ -1,3 +1,13 @@ |
35 | +media-hub (3.2.0+15.04.20150904-0ubuntu1) UNRELEASED; urgency=medium |
36 | + |
37 | + * Make sure the correct player is set as the current player controled by |
38 | + MPRIS. |
39 | + * Improved the can_go_next() and can_go_previous() logic to always return |
40 | + true if the loop_status is currently set to loop over the entire |
41 | + playlist. |
42 | + |
43 | + -- phablet <phablet@ubuntu-phablet> Tue, 08 Sep 2015 17:18:15 -0400 |
44 | + |
45 | media-hub (3.1.0+15.04.20150904-0ubuntu1) vivid; urgency=medium |
46 | |
47 | [ Alfonso Sanchez-Beato (email Canonical) ] |
48 | |
49 | === modified file 'include/core/media/service.h' |
50 | --- include/core/media/service.h 2015-04-14 02:43:56 +0000 |
51 | +++ include/core/media/service.h 2015-09-09 16:32:06 +0000 |
52 | @@ -60,6 +60,9 @@ |
53 | /** @brief Resumes a fixed-name session directly by player key. */ |
54 | virtual std::shared_ptr<Player> resume_session(Player::PlayerKey) = 0; |
55 | |
56 | + /** @brief Sets the current player that the MPRIS interface will control */ |
57 | + virtual void set_current_player(Player::PlayerKey) = 0; |
58 | + |
59 | /** @brief Pauses sessions other than the supplied one. */ |
60 | virtual void pause_other_sessions(Player::PlayerKey) = 0; |
61 | |
62 | |
63 | === modified file 'src/core/media/mpris/service.h' |
64 | --- src/core/media/mpris/service.h 2015-04-10 16:13:55 +0000 |
65 | +++ src/core/media/mpris/service.h 2015-09-09 16:32:06 +0000 |
66 | @@ -115,6 +115,7 @@ |
67 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(DestroySession, Service, 1000) |
68 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(CreateFixedSession, Service, 1000) |
69 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(ResumeSession, Service, 1000) |
70 | + DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(SetCurrentPlayer, Service, 1000) |
71 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(PauseOtherSessions, Service, 1000) |
72 | }; |
73 | } |
74 | |
75 | === modified file 'src/core/media/player_implementation.cpp' |
76 | --- src/core/media/player_implementation.cpp 2015-07-27 22:15:33 +0000 |
77 | +++ src/core/media/player_implementation.cpp 2015-09-09 16:32:06 +0000 |
78 | @@ -376,13 +376,15 @@ |
79 | |
80 | std::function<bool()> can_go_next_getter = [this]() |
81 | { |
82 | - return d->track_list->has_next(); |
83 | + // If LoopStatus == playlist, then there is always a next track |
84 | + return d->track_list->has_next() or Parent::loop_status() == Player::LoopStatus::playlist; |
85 | }; |
86 | Parent::can_go_next().install(can_go_next_getter); |
87 | |
88 | std::function<bool()> can_go_previous_getter = [this]() |
89 | { |
90 | - return d->track_list->has_previous(); |
91 | + // If LoopStatus == playlist, then there is always a next previous |
92 | + return d->track_list->has_previous() or Parent::loop_status() == Player::LoopStatus::playlist; |
93 | }; |
94 | Parent::can_go_previous().install(can_go_previous_getter); |
95 | |
96 | |
97 | === modified file 'src/core/media/service_implementation.cpp' |
98 | --- src/core/media/service_implementation.cpp 2015-04-17 16:44:30 +0000 |
99 | +++ src/core/media/service_implementation.cpp 2015-09-09 16:32:06 +0000 |
100 | @@ -246,6 +246,11 @@ |
101 | return std::shared_ptr<media::Player>(); |
102 | } |
103 | |
104 | +void media::ServiceImplementation::set_current_player(Player::PlayerKey key) |
105 | +{ |
106 | + // no impl |
107 | +} |
108 | + |
109 | void media::ServiceImplementation::pause_other_sessions(media::Player::PlayerKey key) |
110 | { |
111 | if (not d->configuration.player_store->has_player_for_key(key)) |
112 | |
113 | === modified file 'src/core/media/service_implementation.h' |
114 | --- src/core/media/service_implementation.h 2015-04-16 15:19:35 +0000 |
115 | +++ src/core/media/service_implementation.h 2015-09-09 16:32:06 +0000 |
116 | @@ -49,6 +49,7 @@ |
117 | void destroy_session(const std::string&, const Player::Configuration&); |
118 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); |
119 | std::shared_ptr<Player> resume_session(Player::PlayerKey key); |
120 | + void set_current_player(Player::PlayerKey key); |
121 | void pause_other_sessions(Player::PlayerKey key); |
122 | |
123 | private: |
124 | |
125 | === modified file 'src/core/media/service_skeleton.cpp' |
126 | --- src/core/media/service_skeleton.cpp 2015-08-11 16:10:14 +0000 |
127 | +++ src/core/media/service_skeleton.cpp 2015-09-09 16:32:06 +0000 |
128 | @@ -91,6 +91,11 @@ |
129 | &Private::handle_resume_session, |
130 | this, |
131 | std::placeholders::_1)); |
132 | + object->install_method_handler<mpris::Service::SetCurrentPlayer>( |
133 | + std::bind( |
134 | + &Private::handle_set_current_player, |
135 | + this, |
136 | + std::placeholders::_1)); |
137 | object->install_method_handler<mpris::Service::PauseOtherSessions>( |
138 | std::bind( |
139 | &Private::handle_pause_other_sessions, |
140 | @@ -102,7 +107,7 @@ |
141 | { |
142 | static unsigned int session_counter = 0; |
143 | |
144 | - unsigned int current_session = session_counter++; |
145 | + const unsigned int current_session = session_counter++; |
146 | boost::uuids::uuid uuid = gen(); |
147 | |
148 | std::stringstream ss; |
149 | @@ -134,7 +139,8 @@ |
150 | configuration.player_store->add_player_for_key(key, impl->create_session(config)); |
151 | uuid_player_map.insert(std::make_pair(uuid, key)); |
152 | |
153 | - request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), [this, key, msg](const media::apparmor::ubuntu::Context& context) |
154 | + request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), |
155 | + [this, key, msg](const media::apparmor::ubuntu::Context& context) |
156 | { |
157 | fprintf(stderr, "%s():%d -- app_name='%s', attached\n", __func__, __LINE__, context.str().c_str()); |
158 | player_owner_map.insert(std::make_pair(key, std::make_tuple(context.str(), true, msg->sender()))); |
159 | @@ -213,7 +219,8 @@ |
160 | ss << "/core/ubuntu/media/Service/sessions/" << key; |
161 | dbus::types::ObjectPath op{ss.str()}; |
162 | |
163 | - request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), [this, msg, key, op](const media::apparmor::ubuntu::Context& context) |
164 | + request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), |
165 | + [this, msg, key, op](const media::apparmor::ubuntu::Context& context) |
166 | { |
167 | auto info = player_owner_map.at(key); |
168 | fprintf(stderr, "%s():%d -- reattach app_name='%s', info='%s', '%s'\n", __func__, __LINE__, context.str().c_str(), std::get<0>(info).c_str(), std::get<2>(info).c_str()); |
169 | @@ -224,6 +231,12 @@ |
170 | // Signal player reconnection |
171 | auto player = configuration.player_store->player_for_key(key); |
172 | player->reconnect(); |
173 | + // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) |
174 | + if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) |
175 | + { |
176 | + std::cout << "Setting current_player" << std::endl; |
177 | + exported.set_current_player(player); |
178 | + } |
179 | |
180 | auto reply = dbus::Message::make_method_return(msg); |
181 | reply->writer() << op; |
182 | @@ -280,7 +293,8 @@ |
183 | // the session is no longer usable. |
184 | uuid_player_map.erase(uuid); |
185 | |
186 | - request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), [this, msg, key](const media::apparmor::ubuntu::Context& context) |
187 | + request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), |
188 | + [this, msg, key](const media::apparmor::ubuntu::Context& context) |
189 | { |
190 | auto info = player_owner_map.at(key); |
191 | fprintf(stderr, "%s():%d -- Destroying app_name='%s', info='%s', '%s'\n", __func__, __LINE__, context.str().c_str(), std::get<0>(info).c_str(), std::get<2>(info).c_str()); |
192 | @@ -424,9 +438,18 @@ |
193 | } |
194 | } |
195 | |
196 | + void handle_set_current_player(const core::dbus::Message::Ptr& msg) |
197 | + { |
198 | + Player::PlayerKey key; |
199 | + msg->reader() >> key; |
200 | + impl->set_current_player(key); |
201 | + |
202 | + auto reply = dbus::Message::make_method_return(msg); |
203 | + impl->access_bus()->send(reply); |
204 | + } |
205 | + |
206 | void handle_pause_other_sessions(const core::dbus::Message::Ptr& msg) |
207 | { |
208 | - std::cout << __PRETTY_FUNCTION__ << std::endl; |
209 | Player::PlayerKey key; |
210 | msg->reader() >> key; |
211 | impl->pause_other_sessions(key); |
212 | @@ -477,20 +500,10 @@ |
213 | return defaults; |
214 | } |
215 | |
216 | - static std::string service_name() |
217 | - { |
218 | - static const bool export_to_indicator_sound_via_mpris |
219 | - { |
220 | - core::posix::this_process::env::get("UBUNTU_MEDIA_HUB_EXPORT_TO_INDICATOR_VIA_MPRIS", "0") == "1" |
221 | - }; |
222 | - |
223 | - return export_to_indicator_sound_via_mpris ? "org.mpris.MediaPlayer2.MediaHub" : |
224 | - "hidden.org.mpris.MediaPlayer2.MediaHub"; |
225 | - } |
226 | - |
227 | explicit Exported(const dbus::Bus::Ptr& bus, const media::CoverArtResolver& cover_art_resolver) |
228 | : bus{bus}, |
229 | - service{dbus::Service::add_service(bus, service_name())}, |
230 | + /* Export MediaHub service interface on dbus */ |
231 | + service{dbus::Service::add_service(bus, "org.mpris.MediaPlayer2.MediaHub")}, |
232 | object{service->add_object_for_path(dbus::types::ObjectPath{"/org/mpris/MediaPlayer2"})}, |
233 | media_player{mpris::MediaPlayer2::Skeleton::Configuration{bus, object, media_player_defaults()}}, |
234 | player{mpris::Player::Skeleton::Configuration{bus, object, player_defaults()}}, |
235 | @@ -500,14 +513,15 @@ |
236 | object->install_method_handler<core::dbus::interfaces::Properties::GetAll>([this](const core::dbus::Message::Ptr& msg) |
237 | { |
238 | // Extract the interface |
239 | - std::string itf; msg->reader() >> itf; |
240 | + std::string interface; |
241 | + msg->reader() >> interface; |
242 | core::dbus::Message::Ptr reply = core::dbus::Message::make_method_return(msg); |
243 | |
244 | - if (itf == mpris::Player::name()) |
245 | + if (interface == mpris::Player::name()) |
246 | reply->writer() << player.get_all_properties(); |
247 | - else if (itf == mpris::MediaPlayer2::name()) |
248 | + else if (interface == mpris::MediaPlayer2::name()) |
249 | reply->writer() << media_player.get_all_properties(); |
250 | - else if (itf == mpris::Playlists::name()) |
251 | + else if (interface == mpris::Playlists::name()) |
252 | reply->writer() << playlists.get_all_properties(); |
253 | |
254 | Exported::bus->send(reply); |
255 | @@ -516,9 +530,9 @@ |
256 | // Setup method handlers for mpris::Player methods. |
257 | auto next = [this](const core::dbus::Message::Ptr& msg) |
258 | { |
259 | - auto sp = current_player.lock(); |
260 | + const auto sp = current_player.lock(); |
261 | |
262 | - if (sp) |
263 | + if (is_multimedia_role()) |
264 | sp->next(); |
265 | |
266 | Exported::bus->send(core::dbus::Message::make_method_return(msg)); |
267 | @@ -527,9 +541,9 @@ |
268 | |
269 | auto previous = [this](const core::dbus::Message::Ptr& msg) |
270 | { |
271 | - auto sp = current_player.lock(); |
272 | + const auto sp = current_player.lock(); |
273 | |
274 | - if (sp) |
275 | + if (is_multimedia_role()) |
276 | sp->previous(); |
277 | |
278 | Exported::bus->send(core::dbus::Message::make_method_return(msg)); |
279 | @@ -538,9 +552,9 @@ |
280 | |
281 | auto pause = [this](const core::dbus::Message::Ptr& msg) |
282 | { |
283 | - auto sp = current_player.lock(); |
284 | + const auto sp = current_player.lock(); |
285 | |
286 | - if (sp) |
287 | + if (is_multimedia_role() and sp->can_pause()) |
288 | sp->pause(); |
289 | |
290 | Exported::bus->send(core::dbus::Message::make_method_return(msg)); |
291 | @@ -549,9 +563,9 @@ |
292 | |
293 | auto stop = [this](const core::dbus::Message::Ptr& msg) |
294 | { |
295 | - auto sp = current_player.lock(); |
296 | + const auto sp = current_player.lock(); |
297 | |
298 | - if (sp) |
299 | + if (is_multimedia_role()) |
300 | sp->stop(); |
301 | |
302 | Exported::bus->send(core::dbus::Message::make_method_return(msg)); |
303 | @@ -560,9 +574,9 @@ |
304 | |
305 | auto play = [this](const core::dbus::Message::Ptr& msg) |
306 | { |
307 | - auto sp = current_player.lock(); |
308 | + const auto sp = current_player.lock(); |
309 | |
310 | - if (sp) |
311 | + if (is_multimedia_role() and sp->can_play()) |
312 | sp->play(); |
313 | |
314 | Exported::bus->send(core::dbus::Message::make_method_return(msg)); |
315 | @@ -571,13 +585,15 @@ |
316 | |
317 | auto play_pause = [this](const core::dbus::Message::Ptr& msg) |
318 | { |
319 | - auto sp = current_player.lock(); |
320 | + const auto sp = current_player.lock(); |
321 | |
322 | - if (sp) |
323 | + if (is_multimedia_role()) |
324 | { |
325 | - if (sp->playback_status() == media::Player::PlaybackStatus::playing) |
326 | + if (sp->playback_status() == media::Player::PlaybackStatus::playing |
327 | + and sp->can_pause()) |
328 | sp->pause(); |
329 | - else if (sp->playback_status() != media::Player::PlaybackStatus::null) |
330 | + else if (sp->playback_status() != media::Player::PlaybackStatus::null |
331 | + and sp->can_play()) |
332 | sp->play(); |
333 | } |
334 | |
335 | @@ -586,94 +602,29 @@ |
336 | object->install_method_handler<mpris::Player::PlayPause>(play_pause); |
337 | } |
338 | |
339 | + inline bool is_multimedia_role() |
340 | + { |
341 | + const auto sp = current_player.lock(); |
342 | + |
343 | + return (sp ? sp->audio_stream_role() == media::Player::AudioStreamRole::multimedia : false); |
344 | + } |
345 | + |
346 | void set_current_player(const std::shared_ptr<media::Player>& cp) |
347 | { |
348 | - unset_current_player(); |
349 | - |
350 | + std::cout << "*** " << __PRETTY_FUNCTION__ << std::endl; |
351 | // We will not keep the object alive. |
352 | current_player = cp; |
353 | |
354 | // And announce that we can be controlled again. |
355 | - player.properties.can_control->set(false); |
356 | - |
357 | - // We wire up player state changes |
358 | - connections.seeked_to = cp->seeked_to().connect([this](std::uint64_t position) |
359 | - { |
360 | - player.signals.seeked_to->emit(position); |
361 | - }); |
362 | - |
363 | - connections.duration_changed = cp->duration().changed().connect([this](std::uint64_t duration) |
364 | - { |
365 | - player.properties.duration->set(duration); |
366 | - }); |
367 | - |
368 | - connections.position_changed = cp->position().changed().connect([this](std::uint64_t position) |
369 | - { |
370 | - player.properties.position->set(position); |
371 | - }); |
372 | - |
373 | - connections.playback_status_changed = cp->playback_status().changed().connect([this](core::ubuntu::media::Player::PlaybackStatus status) |
374 | - { |
375 | - player.properties.playback_status->set(mpris::Player::PlaybackStatus::from(status)); |
376 | - }); |
377 | - |
378 | - connections.loop_status_changed = cp->loop_status().changed().connect([this](core::ubuntu::media::Player::LoopStatus status) |
379 | - { |
380 | - player.properties.loop_status->set(mpris::Player::LoopStatus::from(status)); |
381 | - }); |
382 | - |
383 | - connections.meta_data_changed = cp->meta_data_for_current_track().changed().connect([this](const core::ubuntu::media::Track::MetaData& md) |
384 | - { |
385 | - mpris::Player::Dictionary dict; |
386 | - |
387 | - bool has_title = md.count(xesam::Title::name) > 0; |
388 | - bool has_album_name = md.count(xesam::Album::name) > 0; |
389 | - bool has_artist_name = md.count(xesam::Artist::name) > 0; |
390 | - |
391 | - if (has_title) |
392 | - dict[xesam::Title::name] = dbus::types::Variant::encode(md.get(xesam::Title::name)); |
393 | - if (has_album_name) |
394 | - dict[xesam::Album::name] = dbus::types::Variant::encode(md.get(xesam::Album::name)); |
395 | - if (has_artist_name) |
396 | - dict[xesam::Artist::name] = dbus::types::Variant::encode(md.get(xesam::Artist::name)); |
397 | - |
398 | - dict[mpris::metadata::ArtUrl::name] = dbus::types::Variant::encode( |
399 | - cover_art_resolver( |
400 | - has_title ? md.get(xesam::Title::name) : "", |
401 | - has_album_name ? md.get(xesam::Album::name) : "", |
402 | - has_artist_name ? md.get(xesam::Artist::name) : "")); |
403 | - |
404 | - mpris::Player::Dictionary wrap; |
405 | - wrap[mpris::Player::Properties::Metadata::name()] = dbus::types::Variant::encode(dict); |
406 | - |
407 | - player.signals.properties_changed->emit( |
408 | - std::make_tuple( |
409 | - dbus::traits::Service<mpris::Player::Properties::Metadata::Interface>::interface_name(), |
410 | - wrap, |
411 | - std::vector<std::string>())); |
412 | - }); |
413 | + player.properties.can_control->set(true); |
414 | } |
415 | |
416 | - void unset_current_player() |
417 | + void reset_current_player() |
418 | { |
419 | + std::cout << __PRETTY_FUNCTION__ << std::endl; |
420 | + // And announce that we can no longer be controlled. |
421 | + player.properties.can_control->set(false); |
422 | current_player.reset(); |
423 | - |
424 | - // We disconnect all previous event connections. |
425 | - connections.seeked_to.disconnect(); |
426 | - connections.duration_changed.disconnect(); |
427 | - connections.position_changed.disconnect(); |
428 | - connections.playback_status_changed.disconnect(); |
429 | - connections.loop_status_changed.disconnect(); |
430 | - connections.meta_data_changed.disconnect(); |
431 | - |
432 | - // And announce that we cannot be controlled anymore. |
433 | - player.properties.can_control->set(false); |
434 | - } |
435 | - |
436 | - void unset_if_current(const std::shared_ptr<media::Player>& cp) |
437 | - { |
438 | - if (cp == current_player.lock()) |
439 | - unset_current_player(); |
440 | } |
441 | |
442 | dbus::Bus::Ptr bus; |
443 | @@ -759,6 +710,14 @@ |
444 | return d->configuration.impl->resume_session(key); |
445 | } |
446 | |
447 | +void media::ServiceSkeleton::set_current_player(media::Player::PlayerKey key) |
448 | +{ |
449 | + const auto player = d->configuration.player_store->player_for_key(key); |
450 | + // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) |
451 | + if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) |
452 | + d->exported.set_current_player(player); |
453 | +} |
454 | + |
455 | void media::ServiceSkeleton::pause_other_sessions(media::Player::PlayerKey key) |
456 | { |
457 | d->configuration.impl->pause_other_sessions(key); |
458 | |
459 | === modified file 'src/core/media/service_skeleton.h' |
460 | --- src/core/media/service_skeleton.h 2015-04-16 15:19:35 +0000 |
461 | +++ src/core/media/service_skeleton.h 2015-09-09 16:32:06 +0000 |
462 | @@ -59,6 +59,7 @@ |
463 | void destroy_session(const std::string&, const media::Player::Configuration&); |
464 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); |
465 | std::shared_ptr<Player> resume_session(Player::PlayerKey); |
466 | + void set_current_player(Player::PlayerKey key); |
467 | void pause_other_sessions(Player::PlayerKey key); |
468 | |
469 | void run(); |
470 | |
471 | === modified file 'src/core/media/service_stub.cpp' |
472 | --- src/core/media/service_stub.cpp 2015-04-17 16:44:30 +0000 |
473 | +++ src/core/media/service_stub.cpp 2015-09-09 16:32:06 +0000 |
474 | @@ -139,9 +139,17 @@ |
475 | }); |
476 | } |
477 | |
478 | +void media::ServiceStub::set_current_player(Player::PlayerKey key) |
479 | +{ |
480 | + auto op = d->object->invoke_method_synchronously<mpris::Service::SetCurrentPlayer, |
481 | + void>(key); |
482 | + |
483 | + if (op.is_error()) |
484 | + throw std::runtime_error("Problem setting current player: " + op.error()); |
485 | +} |
486 | + |
487 | void media::ServiceStub::pause_other_sessions(media::Player::PlayerKey key) |
488 | { |
489 | - std::cout << __PRETTY_FUNCTION__ << std::endl; |
490 | auto op = d->object->invoke_method_synchronously<mpris::Service::PauseOtherSessions, |
491 | void>(key); |
492 | |
493 | |
494 | === modified file 'src/core/media/service_stub.h' |
495 | --- src/core/media/service_stub.h 2015-04-10 16:13:55 +0000 |
496 | +++ src/core/media/service_stub.h 2015-09-09 16:32:06 +0000 |
497 | @@ -45,6 +45,7 @@ |
498 | void destroy_session(const std::string& uuid, const Player::Configuration&); |
499 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); |
500 | std::shared_ptr<Player> resume_session(Player::PlayerKey key); |
501 | + void set_current_player(Player::PlayerKey key); |
502 | void pause_other_sessions(Player::PlayerKey key); |
503 | |
504 | private: |
505 | |
506 | === modified file 'src/core/media/track_list_implementation.cpp' |
507 | --- src/core/media/track_list_implementation.cpp 2015-08-11 15:25:50 +0000 |
508 | +++ src/core/media/track_list_implementation.cpp 2015-09-09 16:32:06 +0000 |
509 | @@ -215,8 +215,6 @@ |
510 | |
511 | void media::TrackListImplementation::reset() |
512 | { |
513 | - std::cout << __PRETTY_FUNCTION__ << std::endl; |
514 | - |
515 | // Make sure playback stops |
516 | on_end_of_tracklist()(); |
517 | |
518 | |
519 | === modified file 'src/core/media/track_list_skeleton.cpp' |
520 | --- src/core/media/track_list_skeleton.cpp 2015-08-11 15:25:50 +0000 |
521 | +++ src/core/media/track_list_skeleton.cpp 2015-09-09 16:32:06 +0000 |
522 | @@ -521,7 +521,6 @@ |
523 | |
524 | void media::TrackListSkeleton::reset() |
525 | { |
526 | - std::cout << __PRETTY_FUNCTION__ << std::endl; |
527 | d->current_track = d->empty_iterator; |
528 | } |
529 |
Some minor fixes required. A MP for trunk would be good too.