use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.
the class BeamManager method playVideo.
public void playVideo(StreamInfo info, final MediaPlayer.LaunchListener listener) {
if (!mConnected) {
listener.onError(ServiceCommandError.getError(503));
}
mStreamInfo = info;
String location = info.getStreamUrl();
if (!location.startsWith("http")) {
BeamServer.setCurrentVideo(location);
location = BeamServer.getVideoURL();
}
String subsLocation = null;
SubtitleWrapper subtitle = info.getSubtitle();
if (subtitle != null && subtitle.getFileUri() != null) {
BeamServer.setCurrentSubs(subtitle.getFileUri().getPath());
if (mCurrentDevice.hasCapability(MediaPlayer.Subtitles_Vtt)) {
subsLocation = BeamServer.getSubsURL(BeamServer.VTT);
} else if (mCurrentDevice.hasCapability(MediaPlayer.Subtitles_Srt)) {
subsLocation = BeamServer.getSubsURL(BeamServer.SRT);
}
} else {
BeamServer.removeSubs();
}
try {
URL url = new URL(location);
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
location = uri.toString();
if (subsLocation != null) {
URL subsUrl = new URL(subsLocation);
URI subsUri = new URI(subsUrl.getProtocol(), subsUrl.getUserInfo(), subsUrl.getHost(), subsUrl.getPort(), subsUrl.getPath(), subsUrl.getQuery(), subsUrl.getRef());
subsLocation = subsUri.toString();
}
} catch (MalformedURLException | URISyntaxException e) {
e.printStackTrace();
}
String title = info.getFullTitle();
String imageUrl = info.getPosterImage() == null ? "https://butterproject.org/images/header-logo.png" : info.getPosterImage();
// String url, String mimeType, String title, String description, String iconSrc, boolean shouldLoop, LaunchListener listener
if (mCurrentDevice != null) {
MediaInfo mediaInfo = new MediaInfo(location, subsLocation, "video/mp4", title, "");
mediaInfo.addImages(new ImageInfo(imageUrl));
mCurrentDevice.getCapability(MediaPlayer.class).playMedia(mediaInfo, false, new MediaPlayer.LaunchListener() {
@Override
public void onSuccess(MediaPlayer.MediaLaunchObject object) {
mLaunchSession = object.launchSession;
if (listener != null) {
listener.onSuccess(object);
}
}
@Override
public void onError(ServiceCommandError error) {
Timber.e(error.getMessage());
if (listener != null) {
listener.onError(error);
}
}
});
}
}
use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.
the class AirPlayService method displayImage.
@Override
public void displayImage(MediaInfo mediaInfo, LaunchListener listener) {
String mediaUrl = null;
String mimeType = null;
String title = null;
String desc = null;
String iconSrc = null;
if (mediaInfo != null) {
mediaUrl = mediaInfo.getUrl();
mimeType = mediaInfo.getMimeType();
title = mediaInfo.getTitle();
desc = mediaInfo.getDescription();
if (mediaInfo.getImages() != null && mediaInfo.getImages().size() > 0) {
ImageInfo imageInfo = mediaInfo.getImages().get(0);
iconSrc = imageInfo.getUrl();
}
}
displayImage(mediaUrl, mimeType, title, desc, iconSrc, listener);
}
use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.
the class AirPlayService method playMedia.
@Override
public void playMedia(MediaInfo mediaInfo, boolean shouldLoop, LaunchListener listener) {
String mediaUrl = null;
String mimeType = null;
String title = null;
String desc = null;
String iconSrc = null;
if (mediaInfo != null) {
mediaUrl = mediaInfo.getUrl();
mimeType = mediaInfo.getMimeType();
title = mediaInfo.getTitle();
desc = mediaInfo.getDescription();
if (mediaInfo.getImages() != null && mediaInfo.getImages().size() > 0) {
ImageInfo imageInfo = mediaInfo.getImages().get(0);
iconSrc = imageInfo.getUrl();
}
}
playMedia(mediaUrl, mimeType, title, desc, iconSrc, shouldLoop, listener);
}
use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.
the class DLNAService method playMedia.
@Override
public void playMedia(MediaInfo mediaInfo, boolean shouldLoop, LaunchListener listener) {
String mediaUrl = null;
String subsUrl = null;
String mimeType = null;
String title = null;
String desc = null;
String iconSrc = null;
if (mediaInfo != null) {
mediaUrl = mediaInfo.getUrl();
subsUrl = mediaInfo.getSubsUrl();
mimeType = mediaInfo.getMimeType();
title = mediaInfo.getTitle();
desc = mediaInfo.getDescription();
if (mediaInfo.getImages() != null && mediaInfo.getImages().size() > 0) {
ImageInfo imageInfo = mediaInfo.getImages().get(0);
iconSrc = imageInfo.getUrl();
}
}
displayMedia(mediaUrl, subsUrl, mimeType, title, desc, iconSrc, listener);
}
use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.
the class DLNAService method displayImage.
@Override
public void displayImage(MediaInfo mediaInfo, LaunchListener listener) {
String mediaUrl = null;
String mimeType = null;
String title = null;
String desc = null;
String iconSrc = null;
if (mediaInfo != null) {
mediaUrl = mediaInfo.getUrl();
mimeType = mediaInfo.getMimeType();
title = mediaInfo.getTitle();
desc = mediaInfo.getDescription();
if (mediaInfo.getImages() != null && mediaInfo.getImages().size() > 0) {
ImageInfo imageInfo = mediaInfo.getImages().get(0);
iconSrc = imageInfo.getUrl();
}
}
displayImage(mediaUrl, mimeType, title, desc, iconSrc, listener);
}
Aggregations