use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class BaseVideoActivity method getLocalMediaInfo.
private MediaInfo getLocalMediaInfo(int type, @Nullable VideoData videoData) {
String url = getNetworkUrl(type, videoData);
if (url == null) {
throw new IllegalStateException(" URL == null");
}
MediaInfo mediaInfo;
String contentType;
int mediaType;
if (type == PlayerFragment.TYPE_AUDIO_WEB || type == PlayerFragment.TYPE_AUDIO_LOCAL || type == PlayerFragment.TYPE_AUDIO_LIVE) {
mediaType = MediaMetadata.MEDIA_TYPE_MUSIC_TRACK;
contentType = "audio/mp4";
} else {
mediaType = MediaMetadata.MEDIA_TYPE_MOVIE;
if (url.contains(".mp4")) {
contentType = "video/mp4";
} else {
contentType = "application/x-mpegurl";
}
}
MediaMetadata movieMetadata = new MediaMetadata(mediaType);
if (videoData != null) {
movieMetadata.putString(MediaMetadata.KEY_TITLE, videoData.getTitle());
} else {
movieMetadata.putString(MediaMetadata.KEY_TITLE, "Live");
}
if (videoData != null && videoData.getThumbnails() != null && videoData.getThumbnails().size() > 0) {
Thumbnail thumbnail = videoData.getThumbnails().get(0);
movieMetadata.addImage(new WebImage(Uri.parse(thumbnail.getUrl())));
} else {
movieMetadata.addImage(new WebImage(Uri.EMPTY));
}
mediaInfo = new MediaInfo.Builder(url).setContentType(contentType).setStreamType(MediaInfo.STREAM_TYPE_BUFFERED).setMetadata(movieMetadata).build();
return mediaInfo;
}
use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class VideoActionsHelper method onShareVideo.
public static void onShareVideo(Video video, Application context) {
Intent sendIntent = new Intent();
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String title = video.getTitle();
String imageUrl = "";
if (video.thumbnails != null) {
Thumbnail thumbnail = VideoHelper.getThumbnailByHeight(video, 240);
imageUrl = thumbnail.getUrl();
}
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, SettingsProvider.getInstance().getShareSubject());
String message = String.format(context.getString(R.string.share_message), title, context.getString(R.string.app_name));
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.setType("text/html");
Intent chooserIntent = Intent.createChooser(sendIntent, context.getResources().getText(R.string.menu_share));
chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(chooserIntent);
}
use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class VideoHelper method getThumbnailByHeight.
// TODO: Remove this method after refactoring to use Room for working with database
public static Thumbnail getThumbnailByHeight(Cursor cursor, int height) {
Type thumbnailType = new TypeToken<List<Thumbnail>>() {
}.getType();
List<Thumbnail> thumbnails = new Gson().fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_THUMBNAILS)), thumbnailType);
return getThumbnailByHeight(thumbnails, height);
}
use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class VideoHelper method objectFromCursor.
@NonNull
public static VideoData objectFromCursor(@NonNull Cursor cursor) {
Gson gson = new Gson();
VideoData video = VideoData.newVideo(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_ID)), cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_ACTIVE)) == 1, cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_COUNTRY)));
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_CATEGORY)) != null) {
Type categoryType = new TypeToken<List<Category>>() {
}.getType();
video.setCategories(gson.<List<Category>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_CATEGORY)), categoryType));
}
video.setCreatedAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_CREATED_AT)));
video.setDescription(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_DESCRIPTION)));
video.setDiscoveryUrl(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_DISCOVERY_URL)));
video.setDuration(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_DURATION)));
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_GUESTS)) != null) {
Type guestsType = new TypeToken<List<ZObject>>() {
}.getType();
video.setGuests(gson.<List<ZObject>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_GUESTS)), guestsType));
}
video.setEpisode(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_EPISODE)));
video.setExpireAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_EXPIRE_AT)));
video.setFeatured(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_FEATURED)) == 1);
video.setForeignId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_FOREIGN_ID)));
video.setMatureContent(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_MATURE_CONTENT)) == 1);
video.setOnAir(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_ON_AIR)) == 1);
video.setPlayingPosition(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_PLAY_TIME)));
video.setPlayerAudioUrl(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_PLAYER_AUDIO_URL)));
video.setPlayerVideoUrl(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_PLAYER_VIDEO_URL)));
video.setPublishedAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_PUBLISHED_AT)));
video.setRating(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_RATING)));
video.setRequestCount(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_REQUEST_COUNT)));
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_RELATED_PLAYLIST_IDS)) != null) {
Type relatedPlaylistIdsType = new TypeToken<List<String>>() {
}.getType();
video.setRelatedPlaylistIds(gson.<List<String>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_RELATED_PLAYLIST_IDS)), relatedPlaylistIdsType));
}
video.setSeason(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_SEASON)));
video.setShortDescription(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_SHORT_DESCRIPTION)));
video.setSiteId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_SITE_ID)));
video.setStartAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_START_AT)));
video.setStatus(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_STATUS)));
video.setSubscriptionRequired(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_SUBSCRIPTION_REQUIRED)) == 1);
video.setTitle(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_TITLE)));
try {
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_THUMBNAILS)) != null) {
Type thumbnailType = new TypeToken<List<Thumbnail>>() {
}.getType();
video.setThumbnails(gson.<List<Thumbnail>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_THUMBNAILS)), thumbnailType));
}
} catch (IllegalStateException e) {
Logger.e("objectFromCursor", e);
}
try {
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_IMAGES)) != null) {
Type imageType = new TypeToken<List<Image>>() {
}.getType();
video.setImages(gson.<List<Image>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_IMAGES)), imageType));
}
} catch (IllegalStateException e) {
Logger.e("objectFromCursor", e);
}
video.setUpdatedAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_UPDATED_AT)));
video.setHuluId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_HULU_ID)));
video.setYoutubeId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_YOUTUBE_ID)));
video.setTranscoded(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_TRANSCODED)) == 1);
video.setCrunchyrollId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_CRUNCHYROLL_ID)));
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_KEYWORDS)) != null) {
Type keywordsType = new TypeToken<List<String>>() {
}.getType();
video.setKeywords(gson.<List<String>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_KEYWORDS)), keywordsType));
}
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_VIDEO_ZOBJECTS)) != null) {
Type videoZObjectsType = new TypeToken<List<VideoZobject>>() {
}.getType();
video.setVideoZobjects(gson.<List<VideoZobject>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_VIDEO_ZOBJECTS)), videoZObjectsType));
}
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_ZOBJECT_IDS)) != null) {
Type zObjectIdsType = new TypeToken<List<String>>() {
}.getType();
video.setZobjectIds(gson.<List<String>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_ZOBJECT_IDS)), zObjectIdsType));
}
if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_SEGMENTS)) != null) {
Type segmentType = new TypeToken<List<Segment>>() {
}.getType();
video.setSegments(gson.<List<Segment>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_SEGMENTS)), segmentType));
}
video.setPurchaseRequired(cursor.getInt(cursor.getColumnIndex(Contract.Video.PURCHASE_REQUIRED)) == 1);
video.setRegistrationRequired(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_REGISTRATION_REQUIRED)) == 1);
return video;
}
use of com.zype.android.webapi.model.video.Thumbnail in project zype-android by zype.
the class GalleryRowItemsAdapter method loadThumbnail.
private void loadThumbnail(ViewHolder holder) {
if (holder.item instanceof Video) {
Video 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));
}
}
} else if (holder.item instanceof Playlist) {
Playlist playlist = (Playlist) holder.item;
boolean thumbnailAssigned = false;
if (usePoster && playlist.images != null) {
Image posterThumbnail = VideoHelper.getPosterThumbnail(playlist);
if (posterThumbnail != null) {
thumbnailAssigned = true;
UiUtils.loadImage(posterThumbnail.getUrl(), R.drawable.outline_video_library_white_48, holder.imageThumbnail);
}
}
if (playlist.thumbnails != null && !thumbnailAssigned) {
Type thumbnailType = new TypeToken<List<Thumbnail>>() {
}.getType();
List<Thumbnail> thumbnails = new Gson().fromJson(playlist.thumbnails, thumbnailType);
Thumbnail thumbnail = VideoHelper.getThumbnailByHeight(thumbnails, 240);
if (thumbnail != null) {
UiUtils.loadImage(thumbnail.getUrl(), R.drawable.outline_video_library_white_48, holder.imageThumbnail);
} else {
holder.imageThumbnail.setImageDrawable(ContextCompat.getDrawable(holder.view.getContext(), R.drawable.outline_video_library_white_48));
}
}
}
}
Aggregations