This is the code to upload a video to Youtube using the C# .NET API from a Windows Forms desktop application:
YouTubeRequestSettings settings = new YouTubeRequestSettings("whatwill come here ?",
"my api key",
"my youtube login email", "my youtube login password");
YouTubeRequest request = new YouTubeRequest(settings);
Video newVideo = new Video();
newVideo.Title = "test 1";
newVideo.Tags.Add(new MediaCategory("Gaming", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "test 1 , test 2";
newVideo.Description = "test 3 test 4";
newVideo.YouTubeEntry.Private = false;
newVideo.Tags.Add(new MediaCategory("tag 1, tag 2",
YouTubeNameTable.DeveloperTagSchema));
newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);
newVideo.YouTubeEntry.MediaSource = new MediaFileSource("C:\\test.avi", "video/quicktime");
Video createdVideo = request.Upload(newVideo);
This works. What I'm looking for is the events that get me back the upload progress, so I can show the progress in a progressbar. Ich can register the following events:
request.Service.AsyncOperationProgress +=
new AsyncOperationProgressEventHandler(Service_AsyncOperationProgress);
request.Service.AsyncOperationCompleted +=
new AsyncOperationCompletedEventHandler(Service_AsyncOperationCompleted);
... but they never get fired while uploading. Also, I cannot find any documentation about the .NET api that goes much further than the small video upload example above. So: Are those the wrong events to look for? Just for reference, I'm starting the seemingly synchonous upload in the following code in a background thread:
ThreadPool.QueueUserWorkItem(
delegate
{
try
{
createdVideo = request.Upload(newVideo);
} catch (Exception ex){
Invoke((ThreadStart) delegate{uploadingFailedWithException(ex);});
}
});
Invoke((ThreadStart)readyUploading);
This way I know when the synchonous operation ended, but I'd like to have events for progress updates to the user. Any ideas?