本文整理汇总了C#中Converter.ToGif方法的典型用法代码示例。如果您正苦于以下问题:C# Converter.ToGif方法的具体用法?C# Converter.ToGif怎么用?C# Converter.ToGif使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter.ToGif方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartProcess
public void StartProcess()
{
if (Model.RecordingInfo == null) return;
TodoListItem tiCombineAudio = Model.TodoList[0];
TodoListItem tiEncodeWebm = Model.TodoList[1];
TodoListItem tiConvertGif = Model.TodoList[2];
TodoListItem tiUpload = Model.TodoList[3];
worker = new BackgroundWorker {WorkerSupportsCancellation = true};
worker.DoWork += (ws, we) =>
{
double progressLimitForEachTodo = 100.0 / Model.TodoList.Count;
converter = new Converter(Model.RecordingInfo.Path);
converter.Progress += (s, e) =>
{
double currentTodoProgressPercent = Model.CurrentProgress - (((int) (Model.CurrentProgress / progressLimitForEachTodo)) * progressLimitForEachTodo);
Model.CurrentProgress += ((progressLimitForEachTodo / 100 * e.DonePercentage) - currentTodoProgressPercent) * (progressLimitForEachTodo / 100);
};
// combine audio and video
tiCombineAudio.State = TodoListItemState.Processing;
converter.Combine();
tiCombineAudio.State = TodoListItemState.Finished;
Model.CurrentProgress = progressLimitForEachTodo;
// convert to webm
tiEncodeWebm.State = TodoListItemState.Processing;
converter.ToWebm();
if (converter.FinishedGood)
{
tiEncodeWebm.State = TodoListItemState.Finished;
tiEncodeWebm.Text = tiEncodeWebm.Text + " (" + Model.RecordingInfo.Path + ".webm)";
Model.RecordingInfo.Formats.Add("webm");
}
else
{
tiEncodeWebm.State = TodoListItemState.Failed;
}
Model.CurrentProgress = progressLimitForEachTodo * 2;
// generate gif
tiConvertGif.State = TodoListItemState.Processing;
if (Model.RecordingInfo.Duration <= 30)
{
converter.ToGif();
if (converter.FinishedGood)
{
tiConvertGif.State = TodoListItemState.Finished;
tiConvertGif.Text = tiConvertGif.Text + " (" + Model.RecordingInfo.Path + ".gif)";
Model.RecordingInfo.Formats.Add("gif");
}
else
{
tiConvertGif.State = TodoListItemState.Failed;
}
}
else
{
tiConvertGif.Text = tiConvertGif.Text + " (skipped. limit 30 second)";
tiConvertGif.State = TodoListItemState.Failed;
}
Model.CurrentProgress = progressLimitForEachTodo * 3;
// upload
tiUpload.State = TodoListItemState.Processing;
try
{
uploader = new Uploader(Model.RecordingInfo);
uploader.Progress += (s, e) =>
{
Model.CurrentProgress += (progressLimitForEachTodo / 100 * e.UploadedPercentage) -
Model.CurrentProgress + (progressLimitForEachTodo * 2);
};
uploader.StartSync();
tiUpload.State = TodoListItemState.Finished;
JObject uploaderResponse = uploader.JsonResponse;
Model.RecordingInfo.Url = uploaderResponse["url"].ToString();
Model.RecordingInfo.ActionKey = uploaderResponse["actionKey"].ToString();
}
catch (Exception e)
{
tiUpload.State = TodoListItemState.Failed;
tiUpload.Text = tiUpload.Text + " " + e.Message;
Model.ProgressState = ProgressState.Failed;
}
Model.CurrentProgress = 100;
};
worker.RunWorkerCompleted += (s, e) =>
{
string headerText = "Generated: MP4";
if (tiEncodeWebm.State == TodoListItemState.Finished)
{
headerText += ", WEBM";
}
if (tiConvertGif.State == TodoListItemState.Finished)
{
headerText += ", GIF";
}
//.........这里部分代码省略.........