private static void AddVideoToSlide(string presentationId, string slideId, string videotextTextBoxId)
        {
            SlidesService slidesService = GetSlideServiceClient();

            var slide = GetSlides(presentationId).FirstOrDefault(s => s.ObjectId == slideId);
            // Create a new square text box, using a supplied object ID.
            List <Request> requests = new List <Request>();
            Dimension      pt350    = new Dimension()
            {
                Magnitude = 350.0, Unit = "PT"
            };
            var afflineTransform = new AffineTransform()
            {
                ScaleX     = (1.0),
                ScaleY     = (1.0),
                TranslateX = (350.0),
                TranslateY = (100.0),
                Unit       = ("PT")
            };
            Size size = slide.PageElements.FirstOrDefault().Size;
            var  pageElementProperties = new PageElementProperties()
            {
                PageObjectId = slideId,
                Size         = size,
                Transform    = afflineTransform
            };

            // Insert text into the box, using the object ID given to it.
            requests.Add(new Request()
            {
                CreateVideo = new CreateVideoRequest()
                {
                    ObjectId          = videotextTextBoxId,
                    Id                = "z3iMVQlcuoE",
                    Source            = "YOUTUBE",
                    ElementProperties = pageElementProperties
                }
            });

            // Execute the requests.
            BatchUpdatePresentationRequest body =
                new BatchUpdatePresentationRequest()
            {
                Requests = requests
            };
            BatchUpdatePresentationResponse response =
                slidesService.Presentations.BatchUpdate(body, presentationId).Execute();
            CreateVideoResponse createShapeResponse = response.Replies.First().CreateVideo;

            Console.WriteLine("Created video with ID: " + createShapeResponse.ObjectId);
        }
        public CreateVideoResponse CreateVideo(CreateVideoRequest request)
        {
            var response = new CreateVideoResponse();
            var entity   = CommonLogic.SetMapping <CreateVideoRequest, Video>(request);

            try
            {
                _context.Add(entity);
                _context.SaveChanges();
                response.IsSuccess = true;
            }
            catch
            {
                throw new Exception();
            }
            return(response);
        }
Example #3
0
        //Add a video to an existing course
        private static Response AddToCourseResponse(CreateVideoRequest createVideoResponse)
        {
            CreateVideoResponse ack = new CreateVideoResponse()
            {
                Status = "FAIL", Reason = "Video Creation Failed."
            };
            Response resp = new Response()
            {
                Type = ResponseType.CreateVideo, Status = "OK", Content = ack
            };
            string videoID = Guid.NewGuid().ToString();
            string query   = $"INSERT INTO video_details(videoid, path, thumbnail, title, description, width, height, duration, authorid, authorname, authorimage, course, courseid) VALUES " +
                             $"('{videoID}','/Videos/{videoID}.mp4','/Thumbnails/{videoID}.jpg'," +
                             $"'{RefineContent(createVideoResponse.Title)}','{RefineContent(createVideoResponse.Decription)}','{createVideoResponse.Width}'," +
                             $"'{createVideoResponse.Height}','{createVideoResponse.Duration}','{createVideoResponse.AuthorId}','{RefineContent(createVideoResponse.AuthorName)}'," +
                             $"'/User/{createVideoResponse.AuthorId}.jpg','{RefineContent(createVideoResponse.CourseName)}','{createVideoResponse.CourseId}')";
            DatabaseManager database = new DatabaseManager();

            (MySqlDataReader reader, var Connection) = database.RunQuery(query);
            if (reader != null && reader.RecordsAffected > 0)
            {
                ack.Status  = "OK";
                ack.Reason  = "Success";
                ack.VideoID = videoID;
                query       = $"UPDATE course_details SET videocount = videocount + 1 WHERE courseid='{createVideoResponse.CourseId}'";
                database.RunQuery(query);

                if (createVideoResponse.Tags.Count >= 1)
                {
                    StringBuilder str = new StringBuilder($"INSERT INTO tag_details (tag, videoid) VALUES ('{createVideoResponse.Tags[0]}', '{videoID}')");
                    for (int i = 1; i < createVideoResponse.Tags.Count; i++)
                    {
                        str.Append($", ('{createVideoResponse.Tags[i]}', '{videoID}')");
                    }
                    database.RunQuery(str.ToString());
                }
            }
            Connection.Close();
            return(resp);
        }
Example #4
0
        private async void uploadVideoButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsValid() && !IsEditVideoType)
            {
                progressRing.isActive = true;
                CreateVideoRequest request = new CreateVideoRequest()
                {
                    AuthorId   = SettingsManager.Username,
                    AuthorName = SettingsManager.FullName,
                    CourseId   = CourseID.CourseID,
                    CourseName = CourseID.CourseName,
                    Decription = descriptionTextBlock.Text,
                    Duration   = duration,
                    Height     = videoHeight,
                    Width      = videoWidth,
                    Title      = titleTextBlock.Text,
                    Tags       = new List <string>()
                };

                foreach (Tags tag in tagsContainer.Children)
                {
                    request.Tags.Add(tag.TagName);
                }
                Object resp = await ConnectionManager.SendRequestAsync(request, RequestType.CreateVideo, ResponseType.CreateVideo);

                if (resp != null)
                {
                    CreateVideoResponse response = ((JObject)resp).ToObject <CreateVideoResponse>();
                    string path = Guid.NewGuid().ToString() + ".jpg";
                    File.Copy(thumbnailPath, path);

                    Object response2 = await ConnectionManager.SendVideoFileAsync(chosenVideoPathTextBlock.Text, path, response.Port);

                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                    if (response2 != null)
                    {
                        AppNotificationManager.PushMessage(new AppNotification()
                        {
                            Message = ((JObject)response2).ToObject <Acknowledge>().Reason
                        });
                    }
                    else
                    {
                        AppNotificationManager.PushMessage(new AppNotification()
                        {
                            Message = "Video Upload Failed Failed."
                        });
                    }
                    Close();
                }
                else
                {
                    errorTextBlock.Text = "Connection Error";
                }
                progressRing.isActive = false;
            }
            else if (IsValid() && IsEditVideoType)
            {
                progressRing.isActive = true;
                VideoUpdateRequest request = new VideoUpdateRequest()
                {
                    Title       = titleTextBlock.Text,
                    Description = descriptionTextBlock.Text,
                    IsThumbnailUpdateRequired = thumbnailChosen,
                    Tags = new List <string>()
                };
                foreach (Tags tags in ((WrapPanel)tagsContainer).Children)
                {
                    request.Tags.Add(tags.TagName);
                }
                Object resp = await ConnectionManager.SendRequestAsync(request, RequestType.VideoUpdate, ResponseType.Acknowledge);

                if (resp != null)
                {
                    VideoUpdateResponse ack = ((JObject)resp).ToObject <VideoUpdateResponse>();
                    if (ack.Status == "OK")
                    {
                        try
                        {
                            if (thumbnailChosen)
                            {
                                await ConnectionManager.SendFileAsync(thumbnailPath, null);
                            }
                        }catch (Exception ex)
                        {
                            AppNotificationManager.PushMessage(new AppNotification()
                            {
                                Message = ex.Message
                            });
                            Close();
                        }
                    }
                    errorTextBlock.Text = ack.Reason;
                }
                else
                {
                    errorTextBlock.Text = "Connection Error.";
                }
            }
        }