示例#1
0
        async Task LoadVideoItems()
        {
            foreach (var vid in _videoIds)
            {
                var v = await VideoInfoRequestor.GetYouTubeVideoModel(vid);

                _videosList.Add(v);
            }
        }
        /// <summary>
        ///     This method is where the actual work of requesting/loading the video info from the API
        /// </summary>
        /// <returns>N/A</returns>
        protected override async Task LoadVideo()
        {
            var sourceText = FindViewById <TextView>(Resource.Id.sourceText);

            sourceText.Text = @"Vimeo.com";

            SetYouTubeAuthItems();

            try
            {
                videoId = GetVideoIdFromIntentDataString(Intent.DataString);

                if (ModelCache.IsCached(videoId))
                {
                    vid = ModelCache.GetItem(videoId);
                }
                else
                {
                    vid = await VideoInfoRequestor.GetVimeoVideoModel(videoId).ConfigureAwait(true);
                }

                if (vid != null)
                {
                    vid.VideoFullUrl = Intent.DataString;
                    LoadVideoDetails(vid);

                    if (!vid.IsErrorModel)
                    {
                        ModelCache.Add(vid);
                    }
                }
                else
                {
                    UnableToLoadVideoInfo();
                }
            }
            catch (Exception ex)
            {
                Log.Error($"YTII.{nameof(OnCreate)}", ex.Message);
                UnableToLoadVideoInfo(ex);
            }
        }