Search in sources :

Example 1 with Thumbnail

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));
        }
    }
}
Also used : Video(com.zype.android.Db.Entity.Video) Image(com.zype.android.webapi.model.video.Image) Thumbnail(com.zype.android.webapi.model.video.Thumbnail)

Example 2 with Thumbnail

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));
    }
}
Also used : VideoData(com.zype.android.webapi.model.video.VideoData) ConsumerFavoriteVideoData(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData) Thumbnail(com.zype.android.webapi.model.video.Thumbnail)

Example 3 with Thumbnail

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();
}
Also used : MediaInfo(com.google.android.gms.cast.MediaInfo) MediaMetadata(com.google.android.gms.cast.MediaMetadata) WebImage(com.google.android.gms.common.images.WebImage) Thumbnail(com.zype.android.webapi.model.video.Thumbnail) MediaQueueItem(com.google.android.gms.cast.MediaQueueItem) Uri(android.net.Uri)

Example 4 with Thumbnail

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));
        }
    }
}
Also used : Type(java.lang.reflect.Type) Gson(com.google.gson.Gson) ArrayList(java.util.ArrayList) List(java.util.List) Thumbnail(com.zype.android.webapi.model.video.Thumbnail)

Example 5 with Thumbnail

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);
    }
}
Also used : Type(java.lang.reflect.Type) TypeToken(com.google.gson.reflect.TypeToken) Gson(com.google.gson.Gson) List(java.util.List) Image(com.zype.android.webapi.model.playlist.Image) Thumbnail(com.zype.android.webapi.model.video.Thumbnail)

Aggregations

Thumbnail (com.zype.android.webapi.model.video.Thumbnail)12 Gson (com.google.gson.Gson)6 Type (java.lang.reflect.Type)5 List (java.util.List)5 ArrayList (java.util.ArrayList)4 TypeToken (com.google.gson.reflect.TypeToken)3 Image (com.zype.android.webapi.model.video.Image)3 MediaInfo (com.google.android.gms.cast.MediaInfo)2 MediaMetadata (com.google.android.gms.cast.MediaMetadata)2 WebImage (com.google.android.gms.common.images.WebImage)2 Video (com.zype.android.Db.Entity.Video)2 VideoData (com.zype.android.webapi.model.video.VideoData)2 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 NonNull (androidx.annotation.NonNull)1 MediaQueueItem (com.google.android.gms.cast.MediaQueueItem)1 Playlist (com.zype.android.Db.Entity.Playlist)1 ConsumerFavoriteVideoData (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData)1 Image (com.zype.android.webapi.model.playlist.Image)1