Exemple #1
0
        /// <summary>
        ///   Return list of videos
        /// </summary>
        /// <param name="q"> </param>
        /// <returns> </returns>
        private static IEnumerable <VideoItem> GetVideos(YouTubeQuery q)
        {
            Google.YouTube.YouTubeRequest request = GetRequest();

            IList <VideoItem> videos = new List <VideoItem>();

            try
            {
                var feed = request.Get <Google.YouTube.Video>(q);
                foreach (Google.YouTube.Video item in feed.Entries)
                {
                    var video = new VideoItem
                    {
                        Extension = "youtube",
                        Duration  = Int32.Parse(item.Media.Duration.Seconds),
                        FileName  = item.VideoId,
                        CreatedBy = item.Author,
                        Title     = item.Title
                    };
                    videos.Add(video);
                }
            }
            catch (GDataRequestException gdre)
            {
                Debug.WriteLine(gdre.Message);
                var response = (HttpWebResponse)gdre.Response;
            }

            return(videos);
        }
		void CallYoutube()
		{
			// Android?
			// UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

			// YoutTube Activity confilcts with Android Activity!!! thus prefix!!
			var yreq = new GYT.YouTubeRequest(new GYT.YouTubeRequestSettings("MonoTouchSample", "AI39si4v3E6oIYiI60ndCNDqnPP5lCqO28DSvvDPnQt-Mqia5uPz2e4E-gMSBVwHXwyn_LF1tWox4LyM-0YQd2o4i_3GcXxa2Q"));

			var feed = yreq.GetVideoFeed("xamarinhq");

			// feed.Entries.ToList().ForEach((video) // MikeB's code
			// =>
			foreach (GYT.Video v in feed.Entries)
			{
				data.Add(v.Title);
			}

			int i = 1;
			RunOnUiThread(
			//InvokeOnMainThread(
				delegate
				{
					ListAdapter = new ArrayAdapter<string>(this, Resource.Layout.list_item, data);

					ListView.TextFilterEnabled = true;

					ListView.ItemClick +=new EventHandler<AdapterView.ItemClickEventArgs>(ListView_ItemClick);
							//delegate(object sender, ItemEventArgs args)
					{
						// When clicked, show a toast with the TextView text
						//Toast.MakeText(Application, ((TextView)args.View).Text, ToastLength.Short).Show();
					};

				}
			);
		}
 public IEnumerable<goog.Video> GetVideos()
 {
     goog.YouTubeRequest request = new goog.YouTubeRequest(new goog.YouTubeRequestSettings("Sitefinity", ""));
     Feed<goog.Video> videoFeed = request.Get<goog.Video>(ServiceUri);
     var videoEntries = videoFeed.Entries.OrderBy(k=>k.Updated);
     return videoEntries;
 }