use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class NetcastTVService method launchApplication.
private void launchApplication(final String appName, final String auid, final String contentId, final Launcher.AppLaunchListener listener) {
JSONObject jsonObj = new JSONObject();
try {
jsonObj.put("id", auid);
jsonObj.put("title", appName);
} catch (JSONException e) {
e.printStackTrace();
}
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(auid);
launchSession.setAppName(appName);
launchSession.setService(NetcastTVService.this);
launchSession.setSessionType(LaunchSessionType.App);
Util.postSuccess(listener, launchSession);
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
String requestURL = getUDAPRequestURL(UDAP_PATH_APPTOAPP_COMMAND);
Map<String, String> params = new HashMap<String, String>();
params.put("name", "AppExecute");
params.put("auid", auid);
if (appName != null) {
params.put("appname", appName);
}
if (contentId != null) {
params.put("contentid", contentId);
}
String httpMessage = getUDAPMessageBody(UDAP_API_COMMAND, params);
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, requestURL, httpMessage, responseListener);
request.send();
}
use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class NetcastTVService method getApplication.
public void getApplication(final String appName, final AppInfoListener listener) {
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
final String strObj = (String) response;
AppInfo appId = new AppInfo() {
{
setId(decToHex(strObj));
}
};
Util.postSuccess(listener, appId);
}
@Override
public void onError(ServiceCommandError error) {
if (listener != null)
Util.postError(listener, error);
}
};
String uri = UDAP_PATH_APPTOAPP_DATA + appName;
String requestURL = getUDAPRequestURL(uri);
ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, requestURL, null, responseListener);
command.setHttpMethod(ServiceCommand.TYPE_GET);
command.send();
}
use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class NetcastTVService method launchNetflix.
@Override
public void launchNetflix(final String contentId, final Launcher.AppLaunchListener listener) {
if (!serviceDescription.getModelNumber().equals("4.0")) {
launchApp("Netflix", listener);
return;
}
final String appName = "Netflix";
getApplication(appName, new AppInfoListener() {
@Override
public void onSuccess(final AppInfo appInfo) {
JSONObject jsonObj = new JSONObject();
try {
jsonObj.put("id", appInfo.getId());
jsonObj.put("name", appName);
} catch (JSONException e) {
e.printStackTrace();
}
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(appInfo.getId());
launchSession.setAppName(appName);
launchSession.setService(NetcastTVService.this);
launchSession.setSessionType(LaunchSessionType.App);
Util.postSuccess(listener, launchSession);
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
String requestURL = getUDAPRequestURL(UDAP_PATH_APPTOAPP_COMMAND);
Map<String, String> params = new HashMap<String, String>();
params.put("name", "SearchCMDPlaySDPContent");
params.put("content_type", "1");
params.put("conts_exec_type", "20");
params.put("conts_plex_type_flag", "N");
params.put("conts_search_id", "2023237");
params.put("conts_age", "18");
params.put("exec_id", "netflix");
params.put("item_id", "-Q m=http%3A%2F%2Fapi.netflix.com%2Fcatalog%2Ftitles%2Fmovies%2F" + contentId + "&source_type=4&trackId=6054700&trackUrl=https%3A%2F%2Fapi.netflix.com%2FAPI_APP_ID_6261%3F%23Search%3F");
params.put("app_type", "");
String httpMessage = getUDAPMessageBody(UDAP_API_COMMAND, params);
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(NetcastTVService.this, requestURL, httpMessage, responseListener);
request.send();
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
});
}
use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class NetcastTVService method launchAppStore.
@Override
public void launchAppStore(final String appId, final AppLaunchListener listener) {
if (!serviceDescription.getModelNumber().equals("4.0")) {
// TODO: this will not work in Korea, use Korean name instead
launchApp("LG Smart World", listener);
return;
}
String targetPath = getUDAPRequestURL(ROAP_PATH_APP_STORE);
Map<String, String> params = new HashMap<String, String>();
params.put("name", "SearchCMDPlaySDPContent");
params.put("content_type", "4");
params.put("conts_exec_type", "");
params.put("conts_plex_type_flag", "");
params.put("conts_search_id", "");
params.put("conts_age", "12");
params.put("exec_id", "");
params.put("item_id", HttpMessage.encode(appId));
params.put("app_type", "S");
String httpMessage = getUDAPMessageBody(UDAP_API_COMMAND, params);
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(appId);
// TODO: this will not work in Korea, use Korean name instead
launchSession.setAppName("LG Smart World");
launchSession.setService(NetcastTVService.this);
launchSession.setSessionType(LaunchSessionType.App);
Util.postSuccess(listener, launchSession);
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, targetPath, httpMessage, responseListener);
command.send();
}
use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class NetcastTVService method sendPairingKey.
@Override
public void sendPairingKey(final String pairingKey) {
state = State.PAIRING;
if (!(serviceConfig instanceof NetcastTVServiceConfig)) {
serviceConfig = new NetcastTVServiceConfig(serviceConfig.getServiceUUID());
}
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
state = State.PAIRED;
((NetcastTVServiceConfig) serviceConfig).setPairingKey(pairingKey);
hConnectSuccess();
}
@Override
public void onError(ServiceCommandError error) {
state = State.INITIAL;
if (listener != null)
listener.onConnectionFailure(NetcastTVService.this, error);
}
};
String requestURL = getUDAPRequestURL(UDAP_PATH_PAIRING);
Map<String, String> params = new HashMap<String, String>();
params.put("name", "hello");
params.put("value", pairingKey);
params.put("port", String.valueOf(serviceDescription.getPort()));
String httpMessage = getUDAPMessageBody(UDAP_API_PAIRING, params);
ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, requestURL, httpMessage, responseListener);
command.send();
}
Aggregations