use of com.connectsdk.service.capability.MediaPlayer in project butter-android by butterproject.
the class WebOSTVService method playMedia.
@Override
public void playMedia(final String url, final String mimeType, final String title, final String description, final String iconSrc, final boolean shouldLoop, final MediaPlayer.LaunchListener listener) {
if ("4.0.0".equalsIgnoreCase(this.serviceDescription.getVersion())) {
DeviceService dlnaService = this.getDLNAService();
if (dlnaService != null) {
MediaPlayer mediaPlayer = dlnaService.getAPI(MediaPlayer.class);
if (mediaPlayer != null) {
mediaPlayer.playMedia(url, mimeType, title, description, iconSrc, shouldLoop, listener);
return;
}
}
JSONObject params = null;
try {
params = new JSONObject() {
{
put("target", url);
put("title", title == null ? NULL : title);
put("description", description == null ? NULL : description);
put("mimeType", mimeType == null ? NULL : mimeType);
put("iconSrc", iconSrc == null ? NULL : iconSrc);
put("loop", shouldLoop);
}
};
} catch (JSONException ex) {
ex.printStackTrace();
Util.postError(listener, new ServiceCommandError(-1, ex.getLocalizedMessage(), ex));
}
if (params != null)
this.displayMedia(params, listener);
} else {
final WebAppSession.LaunchListener webAppLaunchListener = new WebAppSession.LaunchListener() {
@Override
public void onError(ServiceCommandError error) {
listener.onError(error);
}
@Override
public void onSuccess(WebAppSession webAppSession) {
webAppSession.playMedia(url, mimeType, title, description, iconSrc, shouldLoop, listener);
}
};
this.getWebAppLauncher().joinWebApp(MEDIA_PLAYER_ID, new WebAppSession.LaunchListener() {
@Override
public void onError(ServiceCommandError error) {
getWebAppLauncher().launchWebApp(MEDIA_PLAYER_ID, webAppLaunchListener);
}
@Override
public void onSuccess(WebAppSession webAppSession) {
webAppSession.playMedia(url, mimeType, title, description, iconSrc, shouldLoop, listener);
}
});
}
}
use of com.connectsdk.service.capability.MediaPlayer in project butter-android by butterproject.
the class WebOSTVService method displayImage.
@Override
public void displayImage(final String url, final String mimeType, final String title, final String description, final String iconSrc, final MediaPlayer.LaunchListener listener) {
if ("4.0.0".equalsIgnoreCase(this.serviceDescription.getVersion())) {
DeviceService dlnaService = this.getDLNAService();
if (dlnaService != null) {
MediaPlayer mediaPlayer = dlnaService.getAPI(MediaPlayer.class);
if (mediaPlayer != null) {
mediaPlayer.displayImage(url, mimeType, title, description, iconSrc, listener);
return;
}
}
JSONObject params = null;
try {
params = new JSONObject() {
{
put("target", url);
put("title", title == null ? NULL : title);
put("description", description == null ? NULL : description);
put("mimeType", mimeType == null ? NULL : mimeType);
put("iconSrc", iconSrc == null ? NULL : iconSrc);
}
};
} catch (JSONException ex) {
ex.printStackTrace();
Util.postError(listener, new ServiceCommandError(-1, ex.getLocalizedMessage(), ex));
}
if (params != null)
this.displayMedia(params, listener);
} else {
final WebAppSession.LaunchListener webAppLaunchListener = new WebAppSession.LaunchListener() {
@Override
public void onError(ServiceCommandError error) {
listener.onError(error);
}
@Override
public void onSuccess(WebAppSession webAppSession) {
webAppSession.displayImage(url, mimeType, title, description, iconSrc, listener);
}
};
this.getWebAppLauncher().joinWebApp(MEDIA_PLAYER_ID, new WebAppSession.LaunchListener() {
@Override
public void onError(ServiceCommandError error) {
getWebAppLauncher().launchWebApp(MEDIA_PLAYER_ID, webAppLaunchListener);
}
@Override
public void onSuccess(WebAppSession webAppSession) {
webAppSession.displayImage(url, mimeType, title, description, iconSrc, listener);
}
});
}
}
Aggregations