C# 如何将多个视频文件同时上传到youtube?

C# 如何将多个视频文件同时上传到youtube?,c#,.net,winforms,google-api,google-api-dotnet-client,C#,.net,Winforms,Google Api,Google Api Dotnet Client,直到现在,我只上传一个视频文件: private void UploadVideo(string FileName, string VideoTitle, string VideoDescription) { try { var youtubeService = new YouTubeService(new BaseClientService.Initializer()

直到现在,我只上传一个视频文件:

private void UploadVideo(string FileName, string VideoTitle, string VideoDescription)
        {
            try
            {
                var youtubeService = new YouTubeService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName = Assembly.GetExecutingAssembly().GetName().Name
                });

                video.Snippet = new VideoSnippet();
                video.Snippet.Title = VideoTitle;
                video.Snippet.Description = VideoDescription;
                video.Snippet.Tags = new string[] { "tag1", "tag2" };
                video.Status = new VideoStatus();
                video.Status.PrivacyStatus = "public";
                using (var fileStream = new FileStream(FileName, FileMode.Open))
                {

                    const int KB = 0x400;
                    var minimumChunkSize = 256 * KB;

                    var videosInsertRequest = youtubeService.Videos.Insert(video,
                        "snippet,status", fileStream, "video/*");
                    videosInsertRequest.ProgressChanged +=
                        videosInsertRequest_ProgressChanged;
                    videosInsertRequest.ResponseReceived +=
                        videosInsertRequest_ResponseReceived;
                    // The default chunk size is 10MB, here will use 1MB.
                    videosInsertRequest.ChunkSize = minimumChunkSize * 3;
                    dt = DateTime.Now;
                    totalBytes = fileStream.Length;
                    videosInsertRequest.Upload();
                    videosInsertRequest.UploadAsync();
                }
            }
            catch (Exception errors)
            {
                string errorss = errors.ToString();
            }
        }
关于上传的描述,它说:上传内容到服务器。此方法是同步的,将一直阻止,直到上载完成

UploadAsync描述是:将内容异步上传到服务器

如果我有一个视频文件列表,我想同时上传它们,我的意思是同时上传一些视频,我该怎么做

或者,如果我使用UploadAsync,那么如果我单击一个按钮,每次它将上载一个不同的文件名视频文件,它们将同时并行上载

换言之,我认为:我的问题应该是,我如何能够同时将多个视频文件上传到youtube

videosInsertRequest.Upload();
有一个完整的事件:

var mResumableUploader = new ResumableUploader(chunkSize);
        mResumableUploader.AsyncOperationCompleted += MResumableUploaderAsyncOperationCompleted;
        mResumableUploader.AsyncOperationProgress += MResumableUploaderAsyncOperationProgress;
mResumableUploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(ru_AsyncOperationCompleted);
        var youTubeAuthenticator = new ClientLoginAuthenticator(appName, ServiceNames.YouTube, uName, passWord);
        youTubeAuthenticator.DeveloperKey = devKey;

        newVideo = new Video();

        newVideo.Title = "video";
        newVideo.Tags.Add(new MediaCategory("Entertainment", YouTubeNameTable.CategorySchema));
        newVideo.Keywords = "video";
        newVideo.Description = "video";
        newVideo.YouTubeEntry.Private = false;
        newVideo.YouTubeEntry.MediaSource = new MediaFileSource(fileName, fileContType);

        var link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads");
        link.Rel = ResumableUploader.CreateMediaRelation;
        newVideo.YouTubeEntry.Links.Add(link);

        Console.WriteLine("Starting upload: ");
        mResumableUploader.InsertAsync(youTubeAuthenticator, newVideo.YouTubeEntry, "inserter");

如果您尝试同时上载多个,可能会出现重复的用户配额问题吗?如果我一次上传10个视频,我仍然只能每秒发送10个请求。所以每个视频每秒只能上传一个块,就像你一次上传一个视频一样,你每秒可以上传10个块。每次我点击一个按钮上传一个新的视频文件,它都会以某种方式将视频文件添加到一个队列中,并自动上传视频文件。我的意思是,一旦上传完一个文件,它会从队列中取出下一个视频文件并上传,依此类推。也许我可以使用一个列表或队列,我的总体想法是有一批视频文件,我会点击一个按钮,然后“忘记”视频文件,如果不是同时,它会一个接一个地上传。问题是。“同步和异步之间的区别是什么”这并没有回答这个问题。请看问题的最后一行:换句话说,我认为:我的问题应该是:如何可以同时将多个视频文件上载到youtube?我更新了他的问题,以便更好地反映实际问题。您的答案仍然使用youtube api v2(gdata)。他使用的是YouTube API v3的当前版本。你的代码在这两个不同的客户端库中不起作用。V2已经被弃用了一段时间,现在真的不建议使用它。
void ru_AsyncOperationCompleted(object sender, AsyncOperationCompletedEventArgs e)
        {

        //upload complete
        YouTubeRequestSettings ytSettings = new YouTubeRequestSettings("myApp", googleDevKey, ytUsername, ytPassword);
        Video v = ytRequest.ParseVideo(e.ResponseStream);
        string videoId = v.VideoId;
        string watchPage = v.WatchPage.ToString();

    }