diff --git a/src/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/com/github/nutomic/controldlna/gui/RouteFragment.java index 9657288..f5ba084 100644 --- a/src/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -300,8 +300,10 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements public void onItemClick(AdapterView a, View v, final int position, long id) { if (mListView.getAdapter() == mRouteAdapter) playlistMode(mRouteAdapter.getItem(position)); - else + else { mMediaRouterPlayService.getService().play(position); + changePlayPauseState(true); + } } /** @@ -417,6 +419,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements // Single tap. mPreviousTapCount = 0; s.play(s.getCurrentTrack()); + changePlayPauseState(true); } }; if (mPreviousTapCount == 1) @@ -428,7 +431,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements } break; case R.id.next: - s.playNext(); + boolean stillPlaying = s.playNext(); + changePlayPauseState(stillPlaying); break; case R.id.repeat: s.toggleRepeatEnabled(); diff --git a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java index 0ae6dd1..4790ec6 100644 --- a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java +++ b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java @@ -315,25 +315,35 @@ public class MediaRouterPlayService extends Service { /** * Plays the track after current in the playlist. + * + * @return True if another item is played, false if the end + * of the playlist is reached. */ - public void playNext() { + public boolean playNext() { if (mCurrentTrack == -1) - return; + return false; - if (mShuffle) + if (mShuffle) { // Play random item. play(new Random().nextInt(mPlaylist.size())); - else if (mCurrentTrack + 1 < mPlaylist.size()) + return true; + } + else if (mCurrentTrack + 1 < mPlaylist.size()) { // Playlist not over, play next item. play(mCurrentTrack + 1); - else if (mRepeat) + return true; + } + else if (mRepeat) { // Playlist over, repeat it. play(0); + return true; + } else { // Playlist over, stop playback. stop(); if (!mBound) stopSelf(); + return false; } }