use of com.zype.android.webapi.model.video.VideoData in project zype-android by zype.
the class PlayerFragment method attachPlayerToAnalyticsManager.
//
// Analytics
//
private void attachPlayerToAnalyticsManager() {
if (player != null && analytics != null) {
VideoData video = VideoHelper.getVideo(getActivity().getContentResolver(), fileId);
AnalyticsDimensions dimensions = analytics.getDimensions();
Context context = getActivity().getApplicationContext();
String beacon = analytics.getBeacon();
String videoUrl = video.getPlayerVideoUrl();
Map<String, String> customDimensions = getCustomDimensions(video, dimensions);
AnalyticsManager manager = AnalyticsManager.getInstance();
manager.trackPlay(context, player, beacon, videoUrl, customDimensions);
}
}
use of com.zype.android.webapi.model.video.VideoData in project zype-android by zype.
the class VideoHelper method getDownloadedData.
@Nullable
private static VideoData getDownloadedData(ContentResolver contentResolver, String videoId) {
if (TextUtils.isEmpty(videoId)) {
return null;
}
VideoData videoData = null;
Cursor cursor = CursorHelper.getVideoCursor(contentResolver, videoId);
if (cursor != null) {
if (cursor.moveToFirst()) {
videoData = VideoHelper.objectFromCursor(cursor);
videoData = VideoHelper.getDownloadedData(cursor, videoData);
videoData.adSchedule = VideoHelper.getAdSchedule(contentResolver, videoData.getId());
} else {
return null;
// throw new IllegalStateException("DB not contains video with ID=" + videoId);
}
cursor.close();
}
return videoData;
}
use of com.zype.android.webapi.model.video.VideoData in project zype-android by zype.
the class VideoHelper method getVideo.
@Nullable
public static VideoData getVideo(ContentResolver contentResolver, @Nullable String videoId) throws IllegalStateException {
if (TextUtils.isEmpty(videoId)) {
return null;
}
Cursor cursor = CursorHelper.getVideoCursor(contentResolver, videoId);
VideoData videoData = null;
if (cursor != null) {
if (cursor.moveToFirst()) {
videoData = VideoHelper.objectFromCursor(cursor);
}
cursor.close();
}
return videoData;
}
use of com.zype.android.webapi.model.video.VideoData 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);
}
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);
return video;
}
use of com.zype.android.webapi.model.video.VideoData in project zype-android by zype.
the class BaseVideoActivity method getFragment.
@Nullable
protected Fragment getFragment(boolean isChromeCastConnected, String mVideoId) {
VideoData videoData = VideoHelper.getFullData(getContentResolver(), mVideoId);
Fragment fragment;
if (isChromeCastConnected && mType != TYPE_YOUTUBE) {
MediaInfo localMediaInfo = getLocalMediaInfo(mType, videoData);
MediaInfo remoteMediaInfo = getRemoteMediaInfo(mCastManager);
if (localMediaInfo != null && remoteMediaInfo != null && localMediaInfo.getContentId().equalsIgnoreCase(remoteMediaInfo.getContentId())) {
fragment = ChromecastFragment.newInstance(getLocalMediaInfo(mType, videoData), mVideoId);
} else {
fragment = ChromecastCheckStatusFragment.newInstance(localMediaInfo, mVideoId);
}
} else {
switch(mType) {
case PlayerFragment.TYPE_AUDIO_LOCAL:
fragment = getAudioLocalFragment(videoData.getDownloadAudioPath(), mVideoId);
break;
case PlayerFragment.TYPE_AUDIO_WEB:
fragment = getAudioFragment(videoData.getPlayerAudioUrl(), mVideoId);
break;
case PlayerFragment.TYPE_VIDEO_LOCAL:
fragment = getVideoLocalFragment(videoData.getDownloadVideoPath(), mVideoId);
break;
case PlayerFragment.TYPE_VIDEO_WEB:
fragment = getVideoFragment(videoData.getPlayerVideoUrl(), videoData.getAdVideoTag(), videoData.isOnAir(), mVideoId);
break;
case PlayerFragment.TYPE_AUDIO_LIVE:
fragment = getLiveAudioFragment(liveAudioUrlToPlay, mVideoId);
break;
case PlayerFragment.TYPE_VIDEO_LIVE:
fragment = getLiveVideoFragment(liveVideoUrlToPlay, mVideoId);
break;
case TYPE_YOUTUBE:
fragment = getYoutubeFragment(videoData.getId());
break;
case TYPE_WEB:
fragment = null;
break;
default:
throw new IllegalStateException("unknown fragment type " + mType + " mVideoId:" + mVideoId);
}
}
return fragment;
}
Aggregations