use of com.connectsdk.service.sessions.LaunchSession in project butter-android by butterproject.
the class AirPlayService method playVideo.
public void playVideo(final String url, String mimeType, String title, String description, String iconSrc, boolean shouldLoop, final LaunchListener listener) {
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
LaunchSession launchSession = new LaunchSession();
launchSession.setService(AirPlayService.this);
launchSession.setSessionType(LaunchSessionType.Media);
Util.postSuccess(listener, new MediaLaunchObject(launchSession, AirPlayService.this));
startTimer();
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
String uri = getRequestURL("play");
String payload = null;
PListBuilder builder = new PListBuilder();
builder.putString("Content-Location", url);
builder.putReal("Start-Position", 0);
payload = builder.toString();
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, payload, responseListener);
request.send();
}
use of com.connectsdk.service.sessions.LaunchSession in project butter-android by butterproject.
the class DLNAService method displayMedia.
public void displayMedia(String url, String subsUrl, String mimeType, String title, String description, String iconSrc, final LaunchListener listener) {
final String instanceId = "0";
String[] mediaElements = mimeType.split("/");
String mediaType = mediaElements[0];
String mediaFormat = mediaElements[1];
if (mediaType == null || mediaType.length() == 0 || mediaFormat == null || mediaFormat.length() == 0) {
Util.postError(listener, new ServiceCommandError(0, "You must provide a valid mimeType (audio/*, video/*, etc)", null));
return;
}
mediaFormat = "mp3".equals(mediaFormat) ? "mpeg" : mediaFormat;
String mMimeType = String.format("%s/%s", mediaType, mediaFormat);
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
String method = "Play";
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("Speed", "1");
String payload = getMessageXml(AV_TRANSPORT_URN, method, "0", parameters);
ResponseListener<Object> playResponseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
LaunchSession launchSession = new LaunchSession();
launchSession.setService(DLNAService.this);
launchSession.setSessionType(LaunchSessionType.Media);
Util.postSuccess(listener, new MediaLaunchObject(launchSession, DLNAService.this, DLNAService.this));
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(DLNAService.this, method, payload, playResponseListener);
request.send();
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
String method = "SetAVTransportURI";
String metadata = getMetadata(url, subsUrl, mMimeType, title, description, iconSrc);
if (metadata == null) {
Util.postError(listener, ServiceCommandError.getError(500));
return;
}
Map<String, String> params = new LinkedHashMap<String, String>();
try {
params.put("CurrentURI", encodeURL(url));
} catch (Exception e) {
Util.postError(listener, ServiceCommandError.getError(500));
return;
}
params.put("CurrentURIMetaData", metadata);
String payload = getMessageXml(AV_TRANSPORT_URN, method, instanceId, params);
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(DLNAService.this, method, payload, responseListener);
request.send();
}
use of com.connectsdk.service.sessions.LaunchSession in project butter-android by butterproject.
the class WebOSTVService method launchInputPicker.
@Override
public void launchInputPicker(final AppLaunchListener listener) {
final AppInfo appInfo = new AppInfo() {
{
setId("com.webos.app.inputpicker");
setName("InputPicker");
}
};
launchAppWithInfo(appInfo, null, new AppLaunchListener() {
@Override
public void onSuccess(LaunchSession object) {
listener.onSuccess(object);
}
@Override
public void onError(ServiceCommandError error) {
appInfo.setId("com.webos.app.inputmgr");
launchAppWithInfo(appInfo, null, listener);
}
});
}
use of com.connectsdk.service.sessions.LaunchSession in project butter-android by butterproject.
the class WebOSTVService method joinWebApp.
@Override
public void joinWebApp(String webAppId, WebAppSession.LaunchListener listener) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(webAppId);
launchSession.setSessionType(LaunchSessionType.WebApp);
launchSession.setService(this);
joinWebApp(launchSession, listener);
}
use of com.connectsdk.service.sessions.LaunchSession in project butter-android by butterproject.
the class WebOSTVService method launchAppWithInfo.
@Override
public void launchAppWithInfo(final AppInfo appInfo, Object params, final Launcher.AppLaunchListener listener) {
String uri = "ssap://system.launcher/launch";
JSONObject payload = new JSONObject();
final String appId = appInfo.getId();
String contentId = null;
if (params != null) {
try {
contentId = (String) ((JSONObject) params).get("contentId");
} catch (JSONException e) {
e.printStackTrace();
}
}
try {
payload.put("id", appId);
if (contentId != null)
payload.put("contentId", contentId);
if (params != null)
payload.put("params", params);
} catch (JSONException e) {
e.printStackTrace();
}
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
JSONObject obj = (JSONObject) response;
LaunchSession launchSession = new LaunchSession();
launchSession.setService(WebOSTVService.this);
// note that response uses id to mean appId
launchSession.setAppId(appId);
launchSession.setSessionId(obj.optString("sessionId"));
launchSession.setSessionType(LaunchSessionType.App);
Util.postSuccess(listener, launchSession);
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, payload, true, responseListener);
request.send();
}
Aggregations