2011-01-21 169 views
9

下面的代碼失敗了嗎?可能是什麼問題?如何使用C#中的Youtube API將視頻上傳到YouYube?

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

我解決了這個問題。這是我的分類:類別必須是遊戲而不是遊戲

+0

[YouTube API集成ASP.NET - 使用單個頁面上傳視頻]的可能副本(http://stackoverflow.com/questions/629435/youtube-api-integration-asp-net-upload-video-with-一個單頁) – 2011-01-21 21:51:17

回答

5

問題出在您的「遊戲」類別。將您的MediaCategory構造函數更改爲以下內容:

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

它應該適合您。

相關問題