Пример #1
0
        /// <summary>
        /// vzaar uses the oEmbed open standard for allowing 3rd parties to integrated with the vzaar.
        /// </summary>
        /// <param name="videoId"></param>
        /// <returns></returns>
        public VideoDetails getVideoDetails(Int64 videoId)
        {
            var url = apiUrl + "/api/videos/" + videoId + ".json";

            var response = executeRequest(url);
            var jo       = (JObject)JsonConvert.DeserializeObject(response);

            var result = new VideoDetails
            {
                duration = (decimal)jo["duration"],
                type     = (string)jo["type"],
                height   = (int)jo["height"],
                width    = (int)jo["width"],
                url      = (string)jo["video_url"],
                provider = new VideoDetailsProvider
                {
                    name = (string)jo["provider_name"],
                    url  = (string)jo["provider_url"]
                },
                playCount   = (Int64)jo["play_count"],
                videoStatus = new VideoDetailsVideoStatus
                {
                    id          = (int)jo["video_status_id"],
                    description = (string)jo["video_status_description"]
                },
                thumbnail = new VideoDetailsThumbnail
                {
                    height = (int)jo["thumbnail_height"],
                    width  = (int)jo["thumbnail_width"],
                    url    = (string)jo["thumbnail_url"]
                },
                author = new VideoDetailsAuthor
                {
                    name = (string)jo["author_name"],
                    url  = (string)jo["author_url"]
                },
                poster    = "http://view.vzaar.com/" + videoId + "/image",
                html      = (string)jo["html"],
                framegrab = new VideoDetailsFramegrab
                {
                    height = (int)jo["framegrab_height"],
                    width  = (int)jo["framegrab_width"],
                    url    = (string)jo["framegrab_url"]
                },
                totalSize   = (Int64)jo["total_size"],
                title       = (string)jo["title"],
                description = (string)jo["description"]
            };

            return(result);
        }
Пример #2
0
        /// <summary>
        /// vzaar uses the oEmbed open standard for allowing 3rd parties to integrated with the vzaar.
        /// </summary>
        /// <param name="videoId"></param>
        /// <returns></returns>
        public VideoDetails getVideoDetails(Int64 videoId)
        {
            var url = apiUrl + "/api/videos/" + videoId + ".json";

            var response = executeRequest(url);
            var jo = (JObject)JsonConvert.DeserializeObject(response);
            var result = new VideoDetails();

            try
            {
                result = new VideoDetails
                {
                    duration = String.IsNullOrEmpty(jo["duration"].ToString()) ? 0 : decimal.Parse(jo["duration"].ToString()),
                    type = (string)jo["type"],
                    height = String.IsNullOrEmpty(jo["height"].ToString()) ? 0 : int.Parse(jo["height"].ToString()),
                    width = String.IsNullOrEmpty(jo["width"].ToString()) ? 0 : int.Parse(jo["width"].ToString()),
                    url = (string)jo["video_url"],
                    provider = new VideoDetailsProvider
                    {
                        name = (string)jo["provider_name"],
                        url = (string)jo["provider_url"]
                    },
                    playCount = String.IsNullOrEmpty(jo["play_count"].ToString()) ? 0 : Int64.Parse(jo["play_count"].ToString()),
                    videoStatus = new VideoDetailsVideoStatus
                    {
                        id = String.IsNullOrEmpty(jo["video_status_id"].ToString()) ? 0 : int.Parse(jo["video_status_id"].ToString()),
                        description = (string)jo["video_status_description"]
                    },
                    thumbnail = new VideoDetailsThumbnail
                    {
                        height = String.IsNullOrEmpty(jo["thumbnail_height"].ToString()) ? 0 : int.Parse(jo["thumbnail_height"].ToString()),
                        width = String.IsNullOrEmpty(jo["thumbnail_width"].ToString()) ? 0 : int.Parse(jo["thumbnail_width"].ToString()),
                        url = (string)jo["thumbnail_url"]
                    },
                    author = new VideoDetailsAuthor
                    {
                        name = (string)jo["author_name"],
                        url = (string)jo["author_url"]
                    },
                    poster = "http://view.vzaar.com/" + videoId + "/image",
                    html = (string)jo["html"],
                    framegrab = new VideoDetailsFramegrab
                    {
                        height = String.IsNullOrEmpty(jo["framegrab_height"].ToString()) ? 0 : int.Parse(jo["framegrab_height"].ToString()),
                        width = String.IsNullOrEmpty(jo["framegrab_width"].ToString()) ? 0 : int.Parse(jo["framegrab_width"].ToString()),
                        url = (string)jo["framegrab_url"]
                    },
                    totalSize = String.IsNullOrEmpty(jo["total_size"].ToString()) ? 0 : Int64.Parse(jo["total_size"].ToString()),
                    title = (string)jo["title"],
                    description = (string)jo["description"]
                };

                var renditions = new List<VideoRendition>();
                JsonConvert.PopulateObject(jo["renditions"].ToString(), renditions);
                result.renditions = renditions;
            }
            catch
            {
                result = new VideoDetails
                {
                    videoStatus = new VideoDetailsVideoStatus
                    {
                        id =
                            String.IsNullOrEmpty(jo["vzaar-api"]["video"]["video_status_id"].ToString())
                                ? 0
                                : int.Parse(jo["vzaar-api"]["video"]["video_status_id"].ToString()),
                        description = (string)jo["vzaar-api"]["video"]["state"]
                    }
                };
            }

            return result;
        }
Пример #3
0
        /// <summary>
        /// vzaar uses the oEmbed open standard for allowing 3rd parties to integrated with the vzaar.
        /// </summary>
        /// <param name="videoId"></param>
        /// <returns></returns>
        public VideoDetails getVideoDetails(Int64 videoId)
        {
            var url = apiUrl + "/api/videos/" + videoId + ".json";

            var response = executeRequest(url);
            var jo       = (JObject)JsonConvert.DeserializeObject(response);
            var result   = new VideoDetails();

            try
            {
                result = new VideoDetails
                {
                    duration = String.IsNullOrEmpty(jo["duration"].ToString()) ? 0 : decimal.Parse(jo["duration"].ToString()),
                    type     = (string)jo["type"],
                    height   = String.IsNullOrEmpty(jo["height"].ToString()) ? 0 : int.Parse(jo["height"].ToString()),
                    width    = String.IsNullOrEmpty(jo["width"].ToString()) ? 0 : int.Parse(jo["width"].ToString()),
                    url      = (string)jo["video_url"],
                    provider = new VideoDetailsProvider
                    {
                        name = (string)jo["provider_name"],
                        url  = (string)jo["provider_url"]
                    },
                    playCount   = String.IsNullOrEmpty(jo["play_count"].ToString()) ? 0 : Int64.Parse(jo["play_count"].ToString()),
                    videoStatus = new VideoDetailsVideoStatus
                    {
                        id          = String.IsNullOrEmpty(jo["video_status_id"].ToString()) ? 0 : int.Parse(jo["video_status_id"].ToString()),
                        description = (string)jo["video_status_description"]
                    },
                    thumbnail = new VideoDetailsThumbnail
                    {
                        height = String.IsNullOrEmpty(jo["thumbnail_height"].ToString()) ? 0 : int.Parse(jo["thumbnail_height"].ToString()),
                        width  = String.IsNullOrEmpty(jo["thumbnail_width"].ToString()) ? 0 : int.Parse(jo["thumbnail_width"].ToString()),
                        url    = (string)jo["thumbnail_url"]
                    },
                    author = new VideoDetailsAuthor
                    {
                        name = (string)jo["author_name"],
                        url  = (string)jo["author_url"]
                    },
                    poster    = "http://view.vzaar.com/" + videoId + "/image",
                    html      = (string)jo["html"],
                    framegrab = new VideoDetailsFramegrab
                    {
                        height = String.IsNullOrEmpty(jo["framegrab_height"].ToString()) ? 0 : int.Parse(jo["framegrab_height"].ToString()),
                        width  = String.IsNullOrEmpty(jo["framegrab_width"].ToString()) ? 0 : int.Parse(jo["framegrab_width"].ToString()),
                        url    = (string)jo["framegrab_url"]
                    },
                    totalSize   = String.IsNullOrEmpty(jo["total_size"].ToString()) ? 0 : Int64.Parse(jo["total_size"].ToString()),
                    title       = (string)jo["title"],
                    description = (string)jo["description"]
                };

                var renditions = new List <VideoRendition>();
                JsonConvert.PopulateObject(jo["renditions"].ToString(), renditions);
                result.renditions = renditions;
            }
            catch
            {
                result = new VideoDetails
                {
                    videoStatus = new VideoDetailsVideoStatus
                    {
                        id =
                            String.IsNullOrEmpty(jo["vzaar-api"]["video"]["video_status_id"].ToString())
                                ? 0
                                : int.Parse(jo["vzaar-api"]["video"]["video_status_id"].ToString()),
                        description = (string)jo["vzaar-api"]["video"]["state"]
                    }
                };
            }

            return(result);
        }