如何使用C#中的Youtube API将视频上传到YouTube?

时间:2011-01-21 21:48:58

标签: c# video upload youtube youtube-api

以下代码失败了吗?可能是什么问题?

 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);

我解决了这个问题。这是我的类别:该类别必须是游戏而不是游戏

1 个答案:

答案 0 :(得分:5)

问题在于您的“游戏”类别。将您的MediaCategory构造函数修改为以下内容:

newVideo.Tags.Add(new MediaCategory("Games", YouTubeNameTable.CategorySchema));

它应该适合你。