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();
}
}
Untill now i used to upload a video file only with the line:
videosInsertRequest.Upload();
And on the description of Upload it says: Uploads the content to the server. This method is sync and will block untill the upload is complete.
And the UploadAsync description say: Uploads the content async to the server.
If i have a List of video files and i want to upload them all parallel i mean to upload some videos at the same time how can i do it ?
Or maybe if i will use UploadAsync so if i click a button and each time it will upload a different file name video file they will be upload at the same time parallel ?
In other words i think that: my question should be how can i upload more then one video file to youtube at the same time ?