diff --git a/src/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/com/github/nutomic/controldlna/gui/RouteFragment.java index 3c42e58..a8f3264 100644 --- a/src/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -110,6 +110,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements mMediaRouterPlayService = (MediaRouterPlayServiceBinder) service; mMediaRouterPlayService.getService().setRouterFragment(RouteFragment.this); mPlaylistAdapter.addAll(mMediaRouterPlayService.getService().getPlaylist()); + receiveIsPlaying(mMediaRouterPlayService.getService().getCurrentTrack()); } public void onServiceDisconnected(ComponentName className) { @@ -447,9 +448,17 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements : "0" + Integer.toString(seconds)); } + /** + * Sent by MediaRouterPlayService when playback of a new track is started. + * + * @param track Index of the track in the playlist. + */ + public void receiveIsPlaying(int track) { + mListView.smoothScrollToPosition(track); + } + /** * Receives information from MediaRouterPlayService about playback status. - * TODO: doc */ public void receivePlaybackStatus(MediaItemStatus status) { int currentTime = (int) status.getContentPosition() / 1000; diff --git a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java index af7ccea..d53fff7 100644 --- a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java +++ b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java @@ -84,7 +84,7 @@ public class MediaRouterPlayService extends Service { /** * The track that is currently being played. */ - private int mCurrentTrack; + private int mCurrentTrack = -1; private String mItemId; @@ -230,6 +230,9 @@ public class MediaRouterPlayService extends Service { new CreateNotificationTask().execute(mPlaylist.get(mCurrentTrack) .getFirstPropertyValue(DIDLObject.Property.UPNP.ALBUM_ART_URI.class)); + + if (mRouterFragment.get() != null) + mRouterFragment.get().receiveIsPlaying(mCurrentTrack); } }); }