Merge lp:~jhodapp/media-hub/player-add-prev-next into lp:media-hub

Proposed by Jim Hodapp
Status: Merged
Approved by: Nick Dedekind
Approved revision: 139
Merged at revision: 143
Proposed branch: lp:~jhodapp/media-hub/player-add-prev-next
Merge into: lp:media-hub
Diff against target: 187 lines (+73/-5)
8 files modified
include/core/media/track_list.h (+12/-0)
src/core/media/gstreamer/playbin.cpp (+0/-1)
src/core/media/player_implementation.cpp (+16/-2)
src/core/media/track_list.cpp (+10/-0)
src/core/media/track_list_skeleton.cpp (+17/-1)
src/core/media/track_list_skeleton.h (+3/-1)
src/core/media/track_list_stub.cpp (+12/-0)
src/core/media/track_list_stub.h (+3/-0)
To merge this branch: bzr merge lp:~jhodapp/media-hub/player-add-prev-next
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+257824@code.launchpad.net

Commit message

Add next/previous track implementation for the Player and can_go_next/previous.

Description of the change

Add next/previous track implementation for the Player and can_go_next/previous.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Added a couple of inline comments.

review: Needs Fixing
Revision history for this message
Jim Hodapp (jhodapp) :
Revision history for this message
Nick Dedekind (nick-dedekind) :
review: Needs Fixing
Revision history for this message
Jim Hodapp (jhodapp) :
Revision history for this message
Jim Hodapp (jhodapp) :
138. By Jim Hodapp

Move has_previous/has/next into base class instead of impl since it called the parent class anyway.

139. By Jim Hodapp

Merged with trunk.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/core/media/track_list.h'
--- include/core/media/track_list.h 2015-04-20 15:45:51 +0000
+++ include/core/media/track_list.h 2015-05-22 21:20:47 +0000
@@ -70,6 +70,18 @@
70 /** Skip to the specified TrackId. Calls stop() and play() on the player if toggle_player_state is true. */70 /** Skip to the specified TrackId. Calls stop() and play() on the player if toggle_player_state is true. */
71 virtual void go_to(const Track::Id& track, bool toggle_player_state) = 0;71 virtual void go_to(const Track::Id& track, bool toggle_player_state) = 0;
7272
73 /** Returns true if there is a next track in the TrackList after the current one playing */
74 bool has_next() const;
75
76 /** Returns true if there is a previous track in the TrackList before the current one playing */
77 bool has_previous() const;
78
79 /** Skip to the next Track in the TrackList if there is one. */
80 virtual Track::Id next() = 0;
81
82 /** Skip to the previous Track in the TrackList if there is one. */
83 virtual Track::Id previous() = 0;
84
7385
74 /** Reorders the tracks such that they are in a random order. */86 /** Reorders the tracks such that they are in a random order. */
75 virtual void shuffle_tracks() = 0;87 virtual void shuffle_tracks() = 0;
7688
=== modified file 'src/core/media/gstreamer/playbin.cpp'
--- src/core/media/gstreamer/playbin.cpp 2015-04-15 17:13:58 +0000
+++ src/core/media/gstreamer/playbin.cpp 2015-05-22 21:20:47 +0000
@@ -510,7 +510,6 @@
510 return std::string();510 return std::string();
511511
512 std::string filename(uri);512 std::string filename(uri);
513 std::cout << "filename: " << filename << std::endl;
514 size_t pos = uri.find("file://");513 size_t pos = uri.find("file://");
515 if (pos != std::string::npos)514 if (pos != std::string::npos)
516 filename = uri.substr(pos + 7, std::string::npos);515 filename = uri.substr(pos + 7, std::string::npos);
517516
=== modified file 'src/core/media/player_implementation.cpp'
--- src/core/media/player_implementation.cpp 2015-05-11 19:20:42 +0000
+++ src/core/media/player_implementation.cpp 2015-05-22 21:20:47 +0000
@@ -316,8 +316,8 @@
316 Parent::can_play().set(true);316 Parent::can_play().set(true);
317 Parent::can_pause().set(true);317 Parent::can_pause().set(true);
318 Parent::can_seek().set(true);318 Parent::can_seek().set(true);
319 Parent::can_go_previous().set(true);319 Parent::can_go_previous().set(false);
320 Parent::can_go_next().set(true);320 Parent::can_go_next().set(false);
321 Parent::is_video_source().set(false);321 Parent::is_video_source().set(false);
322 Parent::is_audio_source().set(false);322 Parent::is_audio_source().set(false);
323 Parent::shuffle().set(false);323 Parent::shuffle().set(false);
@@ -360,6 +360,18 @@
360 };360 };
361 Parent::is_audio_source().install(audio_type_getter);361 Parent::is_audio_source().install(audio_type_getter);
362362
363 std::function<bool()> can_go_next_getter = [this]()
364 {
365 return d->track_list->has_next();
366 };
367 Parent::can_go_next().install(can_go_next_getter);
368
369 std::function<bool()> can_go_previous_getter = [this]()
370 {
371 return d->track_list->has_previous();
372 };
373 Parent::can_go_previous().install(can_go_previous_getter);
374
363 // When the client changes the loop status, make sure to update the TrackList375 // When the client changes the loop status, make sure to update the TrackList
364 Parent::loop_status().changed().connect([this](media::Player::LoopStatus loop_status)376 Parent::loop_status().changed().connect([this](media::Player::LoopStatus loop_status)
365 {377 {
@@ -590,11 +602,13 @@
590template<typename Parent>602template<typename Parent>
591void media::PlayerImplementation<Parent>::next()603void media::PlayerImplementation<Parent>::next()
592{604{
605 d->track_list->next();
593}606}
594607
595template<typename Parent>608template<typename Parent>
596void media::PlayerImplementation<Parent>::previous()609void media::PlayerImplementation<Parent>::previous()
597{610{
611 d->track_list->previous();
598}612}
599613
600template<typename Parent>614template<typename Parent>
601615
=== modified file 'src/core/media/track_list.cpp'
--- src/core/media/track_list.cpp 2014-01-13 21:51:14 +0000
+++ src/core/media/track_list.cpp 2015-05-22 21:20:47 +0000
@@ -33,3 +33,13 @@
33media::TrackList::~TrackList()33media::TrackList::~TrackList()
34{34{
35}35}
36
37bool media::TrackList::has_next() const
38{
39 return false;
40}
41
42bool media::TrackList::has_previous() const
43{
44 return false;
45}
3646
=== modified file 'src/core/media/track_list_skeleton.cpp'
--- src/core/media/track_list_skeleton.cpp 2015-04-20 17:56:05 +0000
+++ src/core/media/track_list_skeleton.cpp 2015-05-22 21:20:47 +0000
@@ -206,7 +206,17 @@
206 return next_track != tracks().get().end();206 return next_track != tracks().get().end();
207}207}
208208
209const media::Track::Id& media::TrackListSkeleton::next()209bool media::TrackListSkeleton::has_previous() const
210{
211 // If we are looping over the entire list, then there is always a previous track
212 if (d->loop_status == media::Player::LoopStatus::playlist)
213 return true;
214
215 std::cout << "has_previous track? " << (d->current_track != tracks().get().begin() ? "yes" : "no") << std::endl;
216 return d->current_track != tracks().get().begin();
217}
218
219media::Track::Id media::TrackListSkeleton::next()
210{220{
211 std::cout << __PRETTY_FUNCTION__ << std::endl;221 std::cout << __PRETTY_FUNCTION__ << std::endl;
212 if (tracks().get().empty())222 if (tracks().get().empty())
@@ -235,6 +245,12 @@
235 return *(d->current_track);245 return *(d->current_track);
236}246}
237247
248media::Track::Id media::TrackListSkeleton::previous()
249{
250 // TODO: Add logic to calculate the previous track
251 return *(d->current_track);
252}
253
238const media::Track::Id& media::TrackListSkeleton::current()254const media::Track::Id& media::TrackListSkeleton::current()
239{255{
240 // Prevent the TrackList from sitting at the end which will cause256 // Prevent the TrackList from sitting at the end which will cause
241257
=== modified file 'src/core/media/track_list_skeleton.h'
--- src/core/media/track_list_skeleton.h 2015-04-20 17:48:48 +0000
+++ src/core/media/track_list_skeleton.h 2015-05-22 21:20:47 +0000
@@ -42,7 +42,9 @@
42 ~TrackListSkeleton();42 ~TrackListSkeleton();
4343
44 bool has_next() const;44 bool has_next() const;
45 const Track::Id& next();45 bool has_previous() const;
46 Track::Id next();
47 Track::Id previous();
46 const Track::Id& current();48 const Track::Id& current();
4749
48 const core::Property<bool>& can_edit_tracks() const;50 const core::Property<bool>& can_edit_tracks() const;
4951
=== modified file 'src/core/media/track_list_stub.cpp'
--- src/core/media/track_list_stub.cpp 2015-04-20 17:48:48 +0000
+++ src/core/media/track_list_stub.cpp 2015-05-22 21:20:47 +0000
@@ -137,6 +137,18 @@
137 throw std::runtime_error("Problem adding track: " + op.error());137 throw std::runtime_error("Problem adding track: " + op.error());
138}138}
139139
140media::Track::Id media::TrackListStub::next()
141{
142 // TODO: Add this to the dbus interface on the server and implement a proper dbus method call
143 return media::Track::Id{"/empty/track/id"};
144}
145
146media::Track::Id media::TrackListStub::previous()
147{
148 // TODO: Add this to the dbus interface on the server and implement a proper dbus method call
149 return media::Track::Id{"/empty/track/id"};
150}
151
140void media::TrackListStub::shuffle_tracks()152void media::TrackListStub::shuffle_tracks()
141{153{
142 std::cerr << "shuffle_tracks() does nothing from the client side" << std::endl;154 std::cerr << "shuffle_tracks() does nothing from the client side" << std::endl;
143155
=== modified file 'src/core/media/track_list_stub.h'
--- src/core/media/track_list_stub.h 2015-04-20 15:45:51 +0000
+++ src/core/media/track_list_stub.h 2015-05-22 21:20:47 +0000
@@ -51,6 +51,9 @@
5151
52 void go_to(const Track::Id& track, bool toggle_player_state);52 void go_to(const Track::Id& track, bool toggle_player_state);
5353
54 Track::Id next();
55 Track::Id previous();
56
54 void shuffle_tracks();57 void shuffle_tracks();
55 void unshuffle_tracks();58 void unshuffle_tracks();
5659

Subscribers

People subscribed via source and target branches