use of org.fourthline.cling.controlpoint.ControlPoint in project BeyondUPnP by kevinshine.
the class PlaybackCommand method stop.
public static void stop() {
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 Stop(avtService) {
@Override
public void success(ActionInvocation invocation) {
Log.i(TAG, "Stop success.");
}
@Override
public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
Log.e(TAG, "Stop failed");
}
});
}
}
use of org.fourthline.cling.controlpoint.ControlPoint in project BeyondUPnP by kevinshine.
the class PlaybackCommand method getMediaInfo.
public static void getMediaInfo(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 GetMediaInfo(avtService) {
@Override
public void received(ActionInvocation invocation, MediaInfo mediaInfo) {
Message msg = Message.obtain(handler, NowplayingFragment.GET_MEDIA_INFO_ACTION);
msg.obj = mediaInfo;
msg.sendToTarget();
}
@Override
public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
Log.e(TAG, "GetMediaInfo failed");
}
});
}
}
use of org.fourthline.cling.controlpoint.ControlPoint in project BeyondUPnP by kevinshine.
the class PlaybackCommand method playNewItem.
public static void playNewItem(final String uri, final String metadata) {
Device device = SystemManager.getInstance().getSelectedDevice();
//Check selected device
if (device == null)
return;
final Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE);
if (avtService != null) {
final ControlPoint cp = SystemManager.getInstance().getControlPoint();
cp.execute(new Stop(avtService) {
@Override
public void success(ActionInvocation invocation) {
cp.execute(new SetAVTransportURI(avtService, uri, metadata) {
@Override
public void success(ActionInvocation invocation) {
//Second,Set Play command.
cp.execute(new Play(avtService) {
@Override
public void success(ActionInvocation invocation) {
Log.i(TAG, "PlayNewItem success:" + uri);
}
@Override
public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
Log.e(TAG, "playNewItem failed");
}
});
}
@Override
public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
}
});
}
@Override
public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
}
});
}
}
use of org.fourthline.cling.controlpoint.ControlPoint 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");
}
});
}
}
use of org.fourthline.cling.controlpoint.ControlPoint in project BeyondUPnP by kevinshine.
the class PlaybackCommand method play.
public static void play() {
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 Play(avtService) {
@Override
public void success(ActionInvocation invocation) {
Log.i(TAG, "Play success.");
}
@Override
public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
Log.e(TAG, "Play failed");
}
});
}
}
Aggregations