private async void Upload(UploadParameters P) { var credential = await Google_auth.requestUserCredentialUpload(P.ProfileName); var youtuberequest = Youtube_request.getYoutubeService(credential); var video = video_constructor.constructVideo(P.Title, P.Description, P.tags, P.category, P.PrivacyStatus); var filePath = P.path; using (var file = new FileStream(filePath, FileMode.Open)) { filesize = file.Length; var uploadRequest = youtuberequest.Videos.Insert(video, "snippet,status", file, "video/*"); uploadRequest.ProgressChanged += new Action <Google.Apis.Upload.IUploadProgress>((p) => ProgressHandler(p, uploadRequest)); uploadRequest.ResponseReceived += uploadRequest_ResponseReceived; await uploadRequest.ResumeAsync(); } }
private void Upload(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(FileName.Text)) { if (!string.IsNullOrEmpty(ProfileComboBox.SelectionBoxItem.ToString())) { string Title = VideoTitle.Text; UploadQueue.Items.Add(UploadEntry.newUploadEntry(Title)); //Upload Queue Entry TabControl.SelectedIndex = 3; //Switches Tab to Upload Queue UploadParameters UploadParameters = new UploadParameters(Title, VideoDescription.Text, VideoTags.Text.Split(','), video_constructor.Categories.Events, GetPrivacyStatus(), FileName.Text, ProfileComboBox.SelectionBoxItem.ToString()); Upload(UploadParameters); } else { MessageBox.Show("Please select a destination Account"); } } else { MessageBox.Show("Please Select a File"); } }