1

我正在尝试使用 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);
}
4

1 回答 1

0

.NET GData 库有一个默认的客户端超时,当上传特别大的视频或使用慢速连接时,很容易触发它。

请参阅http://code.google.com/p/google-gdata/issues/list?can=1&q=timeout了解许多类似报告的示例,以及会增加超时的相关代码更改。

于 2013-01-02T18:24:11.127 回答