我正在尝试使用C#将视频上传到Youtube。 它适用于非常小的视频,但对于较大的视频,上传每次都会中止。 那是我的代码:
public void VideoAPIUpload(Video video)
{
YouTubeRequestSettings settings = new YouTubeRequestSettings("example app", "AI39si4mUhdQfat8Dsd54qDjKSXYYnYxTaIX5PNurJetTvcAPagRvbSSR2o5xDH_obI4TEDvNieOhHEUmD9_cw0qPD51zj_wpA", "Minecraftexpertenerten@gmail.com", "mutter123") { Timeout = -1 }; ;
settings.Maximum = -1;
YouTubeRequest request = new YouTubeRequest(settings);
Google.YouTube.Video newVideo = new Google.YouTube.Video();
newVideo.Title = video.title;
newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
newVideo.Keywords = video.tags;
newVideo.Description = video.description;
newVideo.YouTubeEntry.Private = false;
newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag",
YouTubeNameTable.DeveloperTagSchema));
// alternatively, you could just specify a descriptive string
// newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA");
newVideo.YouTubeEntry.MediaSource = new MediaFileSource("funny_video.flv",
"video/x-flv");
Google.YouTube.Video createdVideo = request.Upload(newVideo);
}
答案 0 :(得分:0)
.NET GData库存在默认的客户端超时,当上传特别大的视频或使用慢速连接时,触发它很容易。
请参阅http://code.google.com/p/google-gdata/issues/list?can=1&q=timeout了解类似报告的许多示例,以及会增加超时的相关代码更改。