static void Main(string[] args) { var definition = new { grid = new { max_rows = 0, video_sources = new string[] { "", "", "" } } }; var videoLayoutJson = @"{grid:{max_rows:1,video_sources:[""*"",""*"",""*""]}}"; var json = JsonConvert.DeserializeAnonymousType(videoLayoutJson, definition); TwilioClient.Init("SKd8aac04eba0fa8ed056c6263990fa85c", "uUiLZ8XytHGuo15BPnU4EuZ5kdywBDWO"); try { var compositionResource = CompositionResource.Create( roomSid: "RM1c1588840e86e29906a0b51f7b3a4b20", audioSources: new List <string> { "*" }, videoLayout: json, //statusCallback: new Uri("http://my.server.org/callbacks"), format: FormatEnum.Mp4); Console.WriteLine($"Composition Resource: {compositionResource.Sid}"); } catch (Exception ex) { Console.WriteLine($"An exception occurred: {ex.Message}"); } }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var composition = CompositionResource.Create(); Console.WriteLine(composition.Sid); }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"status\": \"processing\",\"date_created\": \"2015-07-30T20:00:00Z\",\"date_completed\": null,\"date_deleted\": null,\"sid\": \"CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"room_sid\": \"RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"audio_sources\": [\"RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"user*\"],\"audio_sources_excluded\": [\"RTbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"],\"video_layout\": {\"custom\": {\"video_sources\": [\"user*\"],\"video_sources_excluded\": [\"RTcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"],\"reuse\": \"show_oldest\",\"x_pos\": 100,\"y_pos\": 600,\"z_pos\": 10,\"width\": 800,\"height\": 0,\"max_columns\": 0,\"max_rows\": 0,\"cells_excluded\": [2,3]}},\"trim\": true,\"format\": \"mp4\",\"resolution\": \"1920x1080\",\"bitrate\": 0,\"size\": 0,\"duration\": 0,\"media_external_location\": null,\"encryption_key\": null,\"url\": \"https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"links\": {\"media\": \"https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media\"}}" )); var response = CompositionResource.Create("RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var composition = CompositionResource.Create( roomSid: "RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(composition.Sid); }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"status\": \"processing\",\"date_created\": \"2015-07-30T20:00:00Z\",\"date_completed\": null,\"date_deleted\": null,\"sid\": \"CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"audio_sources\": [\"RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"],\"video_sources\": [],\"video_layout\": \"GRID\",\"resolution\": \"1280x720\",\"format\": \"mp3\",\"bitrate\": 0,\"size\": 0,\"duration\": 1,\"room_sid\": \"RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"url\": \"https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"links\": {\"media\": \"https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media\"}}" )); var response = CompositionResource.Create(client: twilioRestClient); Assert.NotNull(response); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Video, "/v1/Compositions", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { CompositionResource.Create(client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public CompositionResource CreateComposition(string roomSid, List <string> recordingSids) { var compositionOptions = new CreateCompositionOptions { RoomSid = roomSid, //StatusCallback = new Uri("https://dda50c80.ngrok.io/Call/CompositionCallBack"), Format = "mp4", VideoLayout = new { grid = new { video_sources = new List <string> { "*" } } }, AudioSources = new List <string> { "*" } }; TwilioClient.Init(_apiAccountSid, _accountSid); var composition = CompositionResource.Create(compositionOptions); return(composition); }