开发者

How can I upload a video to YouYube using the Youtube API in C#?

开发者 https://www.devze.com 2023-02-05 20:50 出处:网络
The code below fails? What might be the problem? YouTubeRequestSettings settings = new YouTubeRequestSettings(\"whatwill come here ?\",

The code below fails? What might be the problem?

 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 开发者_如何学C4";
            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);

I solved the problem. It was my category: the category has to be Games instead of Gaming.


The problem is with your "Gaming" category. Amend your MediaCategory constructor to the following:

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

and it should work for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号