Current playlist will now be shown whenever a renderer is selected.

This commit is contained in:
Felix Ableitner 2013-06-19 00:20:27 +02:00
parent e4afabe96a
commit 8455fac93d
2 changed files with 11 additions and 5 deletions

View file

@ -283,9 +283,7 @@ public class RendererFragment extends Fragment implements
} }
private void selectRenderer(Device<?, ?, ?> renderer) { private void selectRenderer(Device<?, ?, ?> renderer) {
if (mCurrentRenderer != renderer) { if (mCurrentRenderer != renderer) {
if (mCurrentRenderer != null)
mPlayService.getService().pause();
if (mSubscriptionCallback != null) if (mSubscriptionCallback != null)
mSubscriptionCallback.end(); mSubscriptionCallback.end();
@ -308,6 +306,7 @@ public class RendererFragment extends Fragment implements
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
protected void eventReceived(final GENASubscription sub) { protected void eventReceived(final GENASubscription sub) {
if (getActivity() == null) return;
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
@ -358,6 +357,8 @@ public class RendererFragment extends Fragment implements
}; };
mUpnpService.getControlPoint().execute(mSubscriptionCallback); mUpnpService.getControlPoint().execute(mSubscriptionCallback);
} }
mPlaylistAdapter.clear();
mPlaylistAdapter.addAll(mPlayService.getService().getPlaylist());
mListView.setAdapter(mPlaylistAdapter); mListView.setAdapter(mPlaylistAdapter);
} }

View file

@ -42,6 +42,7 @@ import org.teleal.cling.model.message.UpnpResponse;
import org.teleal.cling.model.meta.Device; import org.teleal.cling.model.meta.Device;
import org.teleal.cling.model.state.StateVariableValue; import org.teleal.cling.model.state.StateVariableValue;
import org.teleal.cling.model.types.ServiceType; 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.Play;
import org.teleal.cling.support.avtransport.callback.SetAVTransportURI; import org.teleal.cling.support.avtransport.callback.SetAVTransportURI;
import org.teleal.cling.support.avtransport.callback.Stop; import org.teleal.cling.support.avtransport.callback.Stop;
@ -226,7 +227,7 @@ public class PlayService extends Service {
public void pause() { public void pause() {
mManuallyStopped.set(true); mManuallyStopped.set(true);
mUpnpService.getControlPoint().execute( mUpnpService.getControlPoint().execute(
new Stop(mAvTransportService) { new Pause(mAvTransportService) {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
@ -250,7 +251,7 @@ public class PlayService extends Service {
public void setRenderer(Device<?, ?, ?> renderer) { public void setRenderer(Device<?, ?, ?> renderer) {
if (mSubscriptionCallback != null) if (mSubscriptionCallback != null)
mSubscriptionCallback.end(); mSubscriptionCallback.end();
if (mRenderer != null) if (mRenderer != null && renderer != mRenderer)
pause(); pause();
mRenderer = renderer; mRenderer = renderer;
@ -349,5 +350,9 @@ public class PlayService extends Service {
public void playPrevious() { public void playPrevious() {
playTrack(mCurrentTrack - 1); playTrack(mCurrentTrack - 1);
} }
public List<Item> getPlaylist() {
return mPlaylist;
}
} }