我想制作一个 WPF 应用程序,从我的网络摄像机获取视频并将其实时发送到我的 youtube 频道。我环顾了所有网站,但没有示例如何使用 c# 将视频直播到 Youtube。google 的网站上有一些示例,但它们是用 PHP、Java 和 Phyton 编写的,但我不知道这种编程语言,所以我无法使用 API。
我试着写了一点,但是没有用。这是我通过 Java 示例编写的代码。
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets { ClientId = "MyClientId", ClientSecret = "MyClientSecret" },
new[] { DriveService.Scope.Drive,
DriveService.Scope.DriveFile },
"My Youtube Channel Name",
CancellationToken.None,
new FileDataStore("Drive.Auth.Store")).Result;
string devkey = "AIzaSyCbxm6g9orAw9PF3MkzTb_0PGbpD3Xo1Qg";
string username = "MyYoutubeChannelEmailAdress";
string password = "MyPassword";
YouTubeRequestSettings youtubereqsetting = new YouTubeRequestSettings("API Project", devkey, username, password);
YouTubeRequest youtubereq = new YouTubeRequest(youtubereqsetting);
LiveBroadcastSnippet broadcastSnippet = new LiveBroadcastSnippet();
broadcastSnippet.Title = "Test Live Stream";
broadcastSnippet.ScheduledStartTime = new DateTime(2015, 3, 12, 19, 00, 00);
broadcastSnippet.ScheduledEndTime = new DateTime(2015, 3, 12, 20, 00, 00);
LiveBroadcastStatus status = new LiveBroadcastStatus();
status.PrivacyStatus = "Private";
LiveBroadcast broadcast = new LiveBroadcast();
broadcast.Kind = "youtube#liveBroadcast";
broadcast.Snippet = broadcastSnippet;
broadcast.Status = status;
Google.Apis.YouTube.v3.LiveBroadcastsResource.InsertRequest liveBroadcastInsert = new Google.Apis.YouTube.v3.LiveBroadcastsResource.InsertRequest(service, broadcast, "");
LiveBroadcast returnLiveBroadcast = liveBroadcastInsert.Execute();
请帮我!?!?!?