Search in sources :

Example 11 with VideoData

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);
    }
}
Also used : Context(android.content.Context) VideoData(com.zype.android.webapi.model.video.VideoData) AnalyticsDimensions(com.zype.android.webapi.model.player.AnalyticsDimensions)

Example 12 with VideoData

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;
}
Also used : VideoData(com.zype.android.webapi.model.video.VideoData) Cursor(android.database.Cursor) Nullable(android.support.annotation.Nullable)

Example 13 with 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;
}
Also used : VideoData(com.zype.android.webapi.model.video.VideoData) Cursor(android.database.Cursor) Nullable(android.support.annotation.Nullable)

Example 14 with 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;
}
Also used : VideoZobject(com.zype.android.webapi.model.video.VideoZobject) Category(com.zype.android.webapi.model.video.Category) Gson(com.google.gson.Gson) Thumbnail(com.zype.android.webapi.model.video.Thumbnail) Segment(com.zype.android.webapi.model.search.Segment) ZObject(com.zype.android.webapi.model.zobjects.ZObject) Type(java.lang.reflect.Type) VideoData(com.zype.android.webapi.model.video.VideoData) ArrayList(java.util.ArrayList) List(java.util.List) NonNull(android.support.annotation.NonNull)

Example 15 with VideoData

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;
}
Also used : MediaInfo(com.google.android.gms.cast.MediaInfo) VideoData(com.zype.android.webapi.model.video.VideoData) YouTubeFragment(com.zype.android.ui.video_details.fragments.video.YouTubeFragment) Fragment(android.support.v4.app.Fragment) ChromecastCheckStatusFragment(com.zype.android.ui.chromecast.ChromecastCheckStatusFragment) ChromecastFragment(com.zype.android.ui.chromecast.ChromecastFragment) PlayerFragment(com.zype.android.ui.player.PlayerFragment) Nullable(android.support.annotation.Nullable)

Aggregations

VideoData (com.zype.android.webapi.model.video.VideoData)16 Cursor (android.database.Cursor)5 Nullable (android.support.annotation.Nullable)5 ArrayList (java.util.ArrayList)5 Subscribe (com.squareup.otto.Subscribe)3 ConsumerFavoriteVideoData (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData)3 Intent (android.content.Intent)2 ConsumerFavoriteVideo (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo)2 Video (com.zype.android.webapi.model.video.Video)2 Notification (android.app.Notification)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Fragment (android.support.v4.app.Fragment)1 View (android.view.View)1 TextView (android.widget.TextView)1