예제 #1
0
        public async void Search(string basedOnVideoId, string query = null)
        {
            YouTubeService service;

            service = new YouTubeService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = App._CRED, ApplicationName = "EwTewb"
            });


            var pls = service.Search.List("snippet");

            pls.Type = "video"; pls.MaxResults = 10;
            if (basedOnVideoId != null)
            {
                pls.RelatedToVideoId = basedOnVideoId;
            }
            if (query != null)
            {
                pls.Q = query;
            }

            SearchListResponse plRes = null;

            try { plRes = await pls.ExecuteAsync(); }
            catch (Exception ex)
            { }


            VideoListItems = new ObservableCollection <VideoUIItem>();

            foreach (var res in plRes.Items)
            {
                if (res.Id.Kind != "youtube#video")
                {
                    continue;
                }

                var evid = new DBVideo
                {
                    VideoId      = res.Id.VideoId,
                    ChannelId    = res.Snippet.ChannelId,
                    ChannelTitle = res.Snippet.ChannelTitle,
                    Description  = res.Snippet.Description,
                    Date         = res.Snippet.PublishedAt ?? default(DateTime),
                    Thumb        = res.Snippet.Thumbnails == null ? "" : (res.Snippet.Thumbnails.Medium?.Url ?? res.Snippet.Thumbnails.Default__?.Url ?? res.Snippet.Thumbnails.Standard?.Url),
                    Title        = res.Snippet.Title,
                };

                var uivid = new VideoUIItem(this, evid)
                {
                };

                VideoListItems.Add(uivid);
            }
        }
예제 #2
0
            public VideoUIItem(VideoListViewModel parent, DBVideo dbVid)
            {
                DBVid = dbVid;
                Title = DBVid?.Title ?? "?";

                //var req = new VideoSearchRequest
                //{
                //};
                ShowCommand = new MvxCommand(() =>
                {
                    Pull();
                });
            }