use of org.fourthline.cling.model.meta.Device in project BeyondUPnP by kevinshine.
the class ContentContainerActivity method loadContent.
private void loadContent() {
SystemManager systemManager = SystemManager.getInstance();
Device device = null;
try {
device = systemManager.getRegistry().getDevice(new UDN(mIdentifierString), false);
} catch (NullPointerException e) {
Log.e(TAG, "Get device error.");
}
if (device != null) {
//Get cds to browse children directories.
Service contentDeviceService = device.findService(SystemManager.CONTENT_DIRECTORY_SERVICE);
//Execute Browse action and init list view
systemManager.getControlPoint().execute(new Browse(contentDeviceService, mObjectId, BrowseFlag.DIRECT_CHILDREN, "*", 0, null, new SortCriterion(true, "dc:title")) {
@Override
public void received(ActionInvocation actionInvocation, DIDLContent didl) {
Message msg = Message.obtain(handler, ADD_OBJECTS, didl);
msg.sendToTarget();
}
@Override
public void updateStatus(Status status) {
}
@Override
public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
}
});
}
}
use of org.fourthline.cling.model.meta.Device 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.model.meta.Device 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.model.meta.Device 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.model.meta.Device 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