Example #1
0
        public static string[] GetAllVideos(BCAPI api, int pageNumber, string query)
        {
            string[] result = null;

            if (api != null)
            {
                List <BrightcoveSDK.VideoFields> videoSearchFields = new List <VideoFields>();
                int           itemsPerPage = 50;
                int           itemCount    = 0;
                BCQueryResult videos       = null;

                videoSearchFields.Add(VideoFields.NAME);

                if (!string.IsNullOrEmpty(query))
                {
                    query = query.Trim();
                }
                else
                {
                    query = string.Empty;
                }

                if (query.Length == 0)
                {
                    videos = api.FindAllVideos(itemsPerPage, BCSortByType.MODIFIED_DATE, BCSortOrderType.DESC, null, null, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                }
                else
                {
                    videos = api.FindVideosByText(query, itemsPerPage, BCSortByType.MODIFIED_DATE, BCSortOrderType.DESC, null, null, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                }

                if (videos != null)
                {
                    itemCount = videos.TotalCount;
                }

                result = new string[videos.TotalCount];

                for (int i = 0; i < videos.Videos.Count; i++)
                {
                    BCVideo video = videos.Videos[i];

                    if (i < itemsPerPage)
                    {
                        result[i] = string.Format(@"{{ ""id"":{0}, ""name"":'{1}', ""thumbnailURL"":'{2}' }}",
                                                  video.id, Util.FixParam(video.name), Util.FixParam(video.thumbnailURL));
                    }
                    else
                    {
                        result[i] = "null";
                    }
                }
            }

            return(result);
        }
Example #2
0
        public static string[] GetAllVideos(BCAPI api, int pageNumber, string query, string order, string sort)
        {
            string[] result = null;

            if (api != null)
            {
                List <BrightcoveSDK.VideoFields> videoSearchFields = new List <VideoFields>();
                int            itemsPerPage = 50;
                int            itemCount    = 0;
                BCQueryResult  videos       = null;
                List <BCVideo> videosSorted = new List <BCVideo>();


                videoSearchFields.Add(VideoFields.NAME);

                if (!string.IsNullOrEmpty(query))
                {
                    query = query.Trim();
                }
                else
                {
                    query = string.Empty;
                }

                if (query.Length == 0)
                {
                    videos = api.FindAllVideos(itemsPerPage, getSort(sort), getOrder(order), null, null, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                }
                else
                {
                    videos = api.FindVideosByText(query, itemsPerPage, getSort(sort), getOrder(order), null, null, MediaDeliveryTypeEnum.DEFAULT, pageNumber, true);
                }

                if (videos != null)
                {
                    itemCount = videos.TotalCount;
                }
                if (sort != null)
                {
                    if (sort.Equals("display name"))
                    {
                        if (order.Equals("ascending"))
                        {
                            videosSorted = videos.Videos.OrderBy(i => i.name).ToList();
                        }
                        else
                        {
                            videosSorted = videos.Videos.OrderByDescending(i => i.name).ToList();
                        }
                    }
                }

                if (videosSorted != null)
                {
                    if (videosSorted.Count == 0)
                    {
                        videosSorted = videos.Videos;
                    }
                }

                result = new string[videosSorted.Count];

                for (int i = 0; i < videosSorted.Count; i++)
                {
                    BCVideo video = videosSorted[i];

                    if (i < itemsPerPage)
                    {
                        result[i] = string.Format(@"{{ ""id"":{0}, ""name"":'{1}', ""thumbnailURL"":'{2}' }}",
                                                  video.id, Util.FixParam(video.name), Util.FixParam(video.thumbnailURL));
                    }
                    else
                    {
                        result[i] = "null";
                    }
                }
            }

            return(result);
        }