private void TranscodeFile(UploadResult result) { StreamableTranscodeResponse transcodeResponse = JsonConvert.DeserializeObject <StreamableTranscodeResponse>(result.Response); if (!string.IsNullOrEmpty(transcodeResponse.Shortcode)) { ProgressManager progress = new ProgressManager(100); if (AllowReportProgress) { OnProgressChanged(progress); } while (!StopUploadRequested) { string statusJson = SendRequest(HttpMethod.GET, URLHelpers.CombineURL(Host, "videos", transcodeResponse.Shortcode)); StreamableStatusResponse response = JsonConvert.DeserializeObject <StreamableStatusResponse>(statusJson); if (response.Status > 2) { result.Errors.Add(response.Message); result.IsSuccess = false; break; } else if (response.Status == 2) { if (AllowReportProgress) { long delta = 100 - progress.Position; progress.UpdateProgress(delta); OnProgressChanged(progress); } result.IsSuccess = true; result.URL = URLHelpers.CombineURL("https://streamable.com", transcodeResponse.Shortcode); break; } if (AllowReportProgress) { long delta = response.Percent - progress.Position; progress.UpdateProgress(delta); OnProgressChanged(progress); } Thread.Sleep(100); } } else { result.Errors.Add("Could not create video"); result.IsSuccess = false; } }
private void TranscodeFile(UploadResult result) { StreamableTranscodeResponse transcodeResponse = JsonConvert.DeserializeObject <StreamableTranscodeResponse>(result.Response); if (!string.IsNullOrEmpty(transcodeResponse.Shortcode)) { ProgressManager progress = new ProgressManager(100); OnProgressChanged(progress); while (!StopUploadRequested) { string statusJson = SendRequest(HttpMethod.GET, URLHelpers.CombineURL(Host, "videos", transcodeResponse.Shortcode)); StreamableStatusResponse response = JsonConvert.DeserializeObject <StreamableStatusResponse>(statusJson); if (response.status > 2) { Errors.Add(response.message); result.IsSuccess = false; break; } else if (response.status == 2) { progress.UpdateProgress(100 - progress.Position); OnProgressChanged(progress); result.IsSuccess = true; if (UseDirectURL && response.files != null && response.files.mp4 != null && !string.IsNullOrEmpty(response.files.mp4.url)) { result.URL = URLHelpers.ForcePrefix(response.files.mp4.url); } else { result.URL = URLHelpers.ForcePrefix(response.url); } break; } progress.UpdateProgress(response.percent - progress.Position); OnProgressChanged(progress); Thread.Sleep(1000); } } else { Errors.Add("Could not create video"); result.IsSuccess = false; } }