use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class VideosAdapter method loadThumbnail.
private void loadThumbnail(ViewHolder holder) {
Video video = holder.item;
boolean thumbnailAssigned = false;
if (usePoster && video.images != null) {
Image posterThumbnail = VideoHelper.getPosterThumbnail(video);
if (posterThumbnail != null) {
thumbnailAssigned = true;
UiUtils.loadImage(posterThumbnail.getUrl(), R.drawable.placeholder_video, holder.imageThumbnail);
}
}
if (video.thumbnails != null && !thumbnailAssigned) {
Thumbnail thumbnail = VideoHelper.getThumbnailByHeight(video, 240);
if (thumbnail != null) {
UiUtils.loadImage(thumbnail.getUrl(), R.drawable.placeholder_video, holder.imageThumbnail);
} else {
holder.imageThumbnail.setImageDrawable(ContextCompat.getDrawable(holder.view.getContext(), R.drawable.placeholder_video));
}
}
}
use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class VideoDetailActivity method showVideoThumbnail.
private void showVideoThumbnail() {
VideoData videoData = VideoHelper.getFullData(getContentResolver(), mVideoId);
List<Thumbnail> thumbnails = videoData.getThumbnails();
layoutImage.setVisibility(View.VISIBLE);
Thumbnail thumbnail = VideoHelper.getThumbnailByHeight(thumbnails, 480);
if (thumbnail != null) {
UiUtils.loadImage(thumbnail.getUrl(), R.drawable.placeholder_video, imageVideo);
} else {
imageVideo.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.placeholder_video));
}
}
use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class PlayerViewModel method buildMediaQueueItem.
public MediaQueueItem buildMediaQueueItem(Video video, String contentUri) {
Logger.d("buildMediaQueueItem(): contentUri=" + contentUri);
int mediaType;
String contentType;
if (playerMode.getValue() == PlayerMode.AUDIO) {
mediaType = MediaMetadata.MEDIA_TYPE_MUSIC_TRACK;
contentType = "audio/mp4";
} else {
mediaType = MediaMetadata.MEDIA_TYPE_MOVIE;
if (contentUri.contains("mp4")) {
contentType = "video/mp4";
} else {
contentType = "application/x-mpegurl";
}
}
MediaMetadata mediaMetadata = new MediaMetadata(mediaType);
mediaMetadata.putString(MediaMetadata.KEY_TITLE, video.title);
Uri imageUri = Uri.EMPTY;
Thumbnail thumbnail = VideoHelper.getThumbnailByHeight(video, 480);
if (thumbnail != null) {
imageUri = Uri.parse(thumbnail.getUrl());
}
mediaMetadata.addImage(new WebImage(imageUri));
MediaInfo mediaInfo = new MediaInfo.Builder(contentUri).setStreamType(MediaInfo.STREAM_TYPE_BUFFERED).setContentType(contentType).setMetadata(mediaMetadata).build();
return new MediaQueueItem.Builder(mediaInfo).build();
}
use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class VideosCursorAdapter method loadImage.
private void loadImage(final Context context, final Cursor cursor, final VideosViewHolder viewHolder) {
final String thumbnailsString = cursor.getString(COL_VIDEO_THUMBNAILS);
if (thumbnailsString != null) {
Type thumbnailType = new TypeToken<List<Thumbnail>>() {
}.getType();
List<Thumbnail> thumbnails = (new Gson().fromJson(thumbnailsString, thumbnailType));
Thumbnail thumbnail = VideoHelper.getThumbnailByHeight(thumbnails, 240);
if (thumbnail != null) {
UiUtils.loadImage(thumbnail.getUrl(), R.drawable.outline_play_circle_filled_white_white_48, viewHolder.thumbnail);
} else {
viewHolder.thumbnail.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.outline_play_circle_filled_white_white_48));
}
}
}
use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class PlaylistCursorAdapter method loadImage.
private void loadImage(final Context context, final Cursor cursor, final PlaylistViewHolder viewHolder) {
final String thumbnailsString = cursor.getString(COL_PLAYLIST_THUMBNAILS);
final String imagesString = cursor.getString(COL_PLAYLIST_IMAGES);
String placeholderUrl = "https://placeholdit.imgix.net/~text?txtsize=40&txt=No%20thumbnail%20available&w=720&h=240";
// Find playlist thumbnail
Image playlistMobileThumbnail = null;
if (imagesString != null) {
Type imageType = new TypeToken<List<Image>>() {
}.getType();
List<Image> images = (new Gson().fromJson(imagesString, imageType));
if (images.size() > 0) {
for (Image image : images) {
if (image.getTitle().equals(PLAYLIST_THUMBNAIL_TITLE)) {
playlistMobileThumbnail = image;
break;
}
}
}
}
if (playlistMobileThumbnail != null) {
UiUtils.loadImage(context, playlistMobileThumbnail.getUrl(), 0, viewHolder.thumbnail, viewHolder.progressBar);
} else if (thumbnailsString != null) {
Type thumbnailType = new TypeToken<List<Thumbnail>>() {
}.getType();
List<Thumbnail> thumbnails = (new Gson().fromJson(thumbnailsString, thumbnailType));
if (thumbnails.size() > 0) {
UiUtils.loadImage(context, thumbnails.get(1).getUrl(), 0, viewHolder.thumbnail, viewHolder.progressBar);
} else {
UiUtils.loadImage(context, placeholderUrl, 0, viewHolder.thumbnail, viewHolder.progressBar);
}
} else {
UiUtils.loadImage(context, placeholderUrl, 0, viewHolder.thumbnail, viewHolder.progressBar);
}
}
Aggregations