From 8455fac93d0679d4fcbde404506ce29e8315a57d Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 19 Jun 2013 00:20:27 +0200 Subject: [PATCH] Current playlist will now be shown whenever a renderer is selected. --- src/com/github/nutomic/controldlna/RendererFragment.java | 7 ++++--- .../github/nutomic/controldlna/service/PlayService.java | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/com/github/nutomic/controldlna/RendererFragment.java b/src/com/github/nutomic/controldlna/RendererFragment.java index fa14e41..73a3723 100644 --- a/src/com/github/nutomic/controldlna/RendererFragment.java +++ b/src/com/github/nutomic/controldlna/RendererFragment.java @@ -283,9 +283,7 @@ public class RendererFragment extends Fragment implements } private void selectRenderer(Device renderer) { - if (mCurrentRenderer != renderer) { - if (mCurrentRenderer != null) - mPlayService.getService().pause(); + if (mCurrentRenderer != renderer) { if (mSubscriptionCallback != null) mSubscriptionCallback.end(); @@ -308,6 +306,7 @@ public class RendererFragment extends Fragment implements @SuppressWarnings("rawtypes") @Override protected void eventReceived(final GENASubscription sub) { + if (getActivity() == null) return; getActivity().runOnUiThread(new Runnable() { @Override @@ -358,6 +357,8 @@ public class RendererFragment extends Fragment implements }; mUpnpService.getControlPoint().execute(mSubscriptionCallback); } + mPlaylistAdapter.clear(); + mPlaylistAdapter.addAll(mPlayService.getService().getPlaylist()); mListView.setAdapter(mPlaylistAdapter); } diff --git a/src/com/github/nutomic/controldlna/service/PlayService.java b/src/com/github/nutomic/controldlna/service/PlayService.java index 0517f91..088152b 100644 --- a/src/com/github/nutomic/controldlna/service/PlayService.java +++ b/src/com/github/nutomic/controldlna/service/PlayService.java @@ -42,6 +42,7 @@ import org.teleal.cling.model.message.UpnpResponse; import org.teleal.cling.model.meta.Device; import org.teleal.cling.model.state.StateVariableValue; import org.teleal.cling.model.types.ServiceType; +import org.teleal.cling.support.avtransport.callback.Pause; import org.teleal.cling.support.avtransport.callback.Play; import org.teleal.cling.support.avtransport.callback.SetAVTransportURI; import org.teleal.cling.support.avtransport.callback.Stop; @@ -226,7 +227,7 @@ public class PlayService extends Service { public void pause() { mManuallyStopped.set(true); mUpnpService.getControlPoint().execute( - new Stop(mAvTransportService) { + new Pause(mAvTransportService) { @SuppressWarnings("rawtypes") @Override @@ -250,7 +251,7 @@ public class PlayService extends Service { public void setRenderer(Device renderer) { if (mSubscriptionCallback != null) mSubscriptionCallback.end(); - if (mRenderer != null) + if (mRenderer != null && renderer != mRenderer) pause(); mRenderer = renderer; @@ -349,5 +350,9 @@ public class PlayService extends Service { public void playPrevious() { playTrack(mCurrentTrack - 1); } + + public List getPlaylist() { + return mPlaylist; + } }