Ejemplo n.º 1
0
        private async void UpdateComments(CommentThreadsResource.ListRequest.OrderEnum option)
        {
            //Clear the current comments
            commentCollection.Clear();

            var methods = new YoutubeMethods();

            //Get the comments
            var service     = YoutubeMethodsStatic.GetServiceNoAuth();
            var getComments = service.CommentThreads.List("snippet,replies");

            getComments.VideoId    = Constants.activeVideoID;
            getComments.Order      = option;
            getComments.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText;
            getComments.MaxResults = 10;
            var response = await getComments.ExecuteAsync();

            //Save the next page token
            commentNextPageToken = response.NextPageToken;

            //Add them to our collection so that they will be updated on the UI
            foreach (var commentThread in response.Items)
            {
                commentCollection.Add(new CommentContainerDataType(methods.CommentToDataType(commentThread)));
            }
        }
Ejemplo n.º 2
0
        private async void ViewMoreButton_Click(Windows.UI.Xaml.Documents.Hyperlink sender, Windows.UI.Xaml.Documents.HyperlinkClickEventArgs args)
        {
            if (!isExpanded)
            {
                isExpanded = !isExpanded;

                //ViewMoreButton.

                var methods = new YoutubeMethods();

                var service    = YoutubeMethodsStatic.GetServiceNoAuth();
                var getReplies = service.Comments.List("snippet");
                getReplies.ParentId   = Source.Id;
                getReplies.TextFormat = Google.Apis.YouTube.v3.CommentsResource.ListRequest.TextFormatEnum.PlainText;
                var response = await getReplies.ExecuteAsync();

                commentReplies.Clear();

                foreach (var item in response.Items)
                {
                    var comment = methods.CommentToDataType(item);

                    //If there are no likes, set it to null
                    if (comment.LikeCount == 0)
                    {
                        comment.LikeCount = null;
                    }
                    commentReplies.Add(comment);
                }
            }
            else
            {
                isExpanded = !isExpanded;

                commentReplies.Clear();

                foreach (var item in Source.Replies)
                {
                    if (commentReplies.Count > 2)
                    {
                        break;
                    }

                    //If there are no likes, set it to null
                    if (item.LikeCount == 0)
                    {
                        item.LikeCount = null;
                    }
                    commentReplies.Add(item);
                }
            }
        }
Ejemplo n.º 3
0
        private async void AddComments(CommentThreadsResource.ListRequest.OrderEnum option)
        {
            if (isAdding)
            {
                return;
            }

            isAdding = true;

            //Check if there are more comments
            if (commentNextPageToken == null || commentNextPageToken == "")
            {
                return;
            }

            var methods = new YoutubeMethods();

            //Get the comments
            var service     = YoutubeMethodsStatic.GetServiceNoAuth();
            var getComments = service.CommentThreads.List("snippet,replies");

            getComments.VideoId    = Constants.activeVideoID;
            getComments.Order      = option;
            getComments.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText;
            getComments.PageToken  = commentNextPageToken;
            getComments.MaxResults = 15;
            var response = await getComments.ExecuteAsync();

            //Save the next page token
            commentNextPageToken = response.NextPageToken;

            //Add them to our collection so that they will be updated on the UI
            foreach (var commentThread in response.Items)
            {
                commentCollection.Add(new CommentContainerDataType(methods.CommentToDataType(commentThread)));
            }

            isAdding = false;
        }