use of org.fourthline.cling.support.avtransport.callback.GetTransportInfo in project BeyondUPnP by kevinshine.
the class PlaybackCommand method getTransportInfo.
public static void getTransportInfo(final Handler handler) {
Device device = SystemManager.getInstance().getSelectedDevice();
//Check selected device
if (device == null)
return;
Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE);
if (avtService != null) {
ControlPoint cp = SystemManager.getInstance().getControlPoint();
cp.execute(new GetTransportInfo(avtService) {
@Override
public void received(ActionInvocation invocation, TransportInfo transportInfo) {
TransportState ts = transportInfo.getCurrentTransportState();
Log.i(TAG, "TransportState:" + ts.getValue());
if (TransportState.PLAYING == ts) {
handler.sendEmptyMessage(NowplayingFragment.PLAY_ACTION);
} else if (TransportState.PAUSED_PLAYBACK == ts) {
handler.sendEmptyMessage(NowplayingFragment.PAUSE_ACTION);
} else if (TransportState.STOPPED == ts) {
handler.sendEmptyMessage(NowplayingFragment.STOP_ACTION);
}
}
@Override
public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
Log.e(TAG, "GetTransportInfo failed");
}
});
}
}
Aggregations